#2 - change filtering
This commit is contained in:
parent
62db77c82e
commit
3de5950389
@ -5,6 +5,7 @@ import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import ru.ulstu.extractor.mvc.model.FilterForm;
|
||||
import ru.ulstu.extractor.mvc.model.RepoForm;
|
||||
|
||||
@Controller
|
||||
@ -16,12 +17,28 @@ public class GitExtractorController {
|
||||
return "newRepo";
|
||||
}
|
||||
|
||||
@GetMapping("/filtering")
|
||||
public String filter(Model model) {
|
||||
model.addAttribute("filterForm", new FilterForm());
|
||||
return "filtering";
|
||||
}
|
||||
|
||||
@PostMapping("/sendRepo")
|
||||
public String sendRepo(@ModelAttribute RepoForm repoForm, Model model) {
|
||||
model.addAttribute("filterForm", new FilterForm());
|
||||
if (repoForm.getRepo() == null || repoForm.getRepo().isEmpty()) {
|
||||
model.addAttribute("error", "'Git' не должно быть пустым");
|
||||
return "newRepo";
|
||||
}
|
||||
return "filtering";
|
||||
}
|
||||
|
||||
@PostMapping("/sendFilter")
|
||||
public String sendFilter(@ModelAttribute FilterForm filterForm, Model model) {
|
||||
if (filterForm.getFilter() == null || filterForm.getFilter().isEmpty()) {
|
||||
model.addAttribute("error", "'Строка' не должно быть пустым");
|
||||
return "filtering";
|
||||
}
|
||||
return "resultRepo";
|
||||
}
|
||||
}
|
||||
|
20
src/main/java/ru/ulstu/extractor/mvc/model/FilterForm.java
Normal file
20
src/main/java/ru/ulstu/extractor/mvc/model/FilterForm.java
Normal file
@ -0,0 +1,20 @@
|
||||
package ru.ulstu.extractor.mvc.model;
|
||||
|
||||
public class FilterForm {
|
||||
private String filter;
|
||||
|
||||
public String getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public void setFilter(String filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FilterForm{" +
|
||||
"subject='" + filter +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ public class RepoForm {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EmailForm{" +
|
||||
return "RepoForm{" +
|
||||
"subject='" + repo +
|
||||
'}';
|
||||
}
|
||||
|
@ -32,14 +32,16 @@
|
||||
</a>
|
||||
</p>
|
||||
<div class="collapse" id="collapseExample">
|
||||
<div class="card card-body">
|
||||
<div th:utext="'Failed URL: ' + ${url}" th:remove="tag">${url}</div>
|
||||
<div th:utext="'Exception: ' + ${exception.message}" th:remove="tag">${exception.message}</div>
|
||||
<ul th:remove="tag">
|
||||
<li th:each="ste : ${exception.stackTrace}" th:remove="tag"><span
|
||||
th:utext="${ste}" th:remove="tag">${ste}</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
<p class="card card-body">
|
||||
<div th:utext="'Failed URL: ' + ${url}" th:remove="tag">${url}</div>
|
||||
<p th:if="${exception}">
|
||||
<div th:utext="'Exception: ' + ${exception.message}" th:remove="tag">${exception.message}</div>
|
||||
</p>
|
||||
<ul th:remove="tag">
|
||||
<li th:each="ste : ${exception.stackTrace}" th:remove="tag"><span
|
||||
th:utext="${ste}" th:remove="tag">${ste}</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</html>
|
@ -1,14 +1,14 @@
|
||||
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
|
||||
<html
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
<title>Простая обработка формы на Spring MVC</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<div class="container" layout:fragment="content">
|
||||
<body>
|
||||
<form name="filtering">
|
||||
<form action="#" th:action="@{/sendFilter}" th:object="${filterForm}" method="post">
|
||||
<p><b>Фильтровать данные:</b><Br></p>
|
||||
По автору
|
||||
<select class="selectpicker" data-live-search="true">
|
||||
@ -26,10 +26,11 @@
|
||||
<option data-tokens="age">год</option>
|
||||
</select>
|
||||
<p>Строки:<br>
|
||||
<input type="text" size="40">
|
||||
<input type="text" size="40" th:field="*{filter}">
|
||||
</p>
|
||||
<p style="color:red" th:text="${error}"></p>
|
||||
<p>
|
||||
<input type="button" value="Отправить" onClick='location.href="result.html"'>
|
||||
<input type="submit" value="Отправить"/>
|
||||
</p>
|
||||
</form>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user