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