3-parse-rule #10

Open
romanov73 wants to merge 9 commits from 3-parse-rule into master
3 changed files with 94 additions and 0 deletions
Showing only changes of commit 8fbd17c63e - Show all commits

View File

@ -6,6 +6,7 @@ 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.fc.rule.model.AddRuleForm; import ru.ulstu.fc.rule.model.AddRuleForm;
import ru.ulstu.fc.rule.model.AddTermForm;
import ru.ulstu.fc.rule.service.RuleParseService; import ru.ulstu.fc.rule.service.RuleParseService;
import java.util.List; import java.util.List;
@ -34,4 +35,16 @@ public class RuleController {
model.addAttribute("addRuleForm", addRuleForm); model.addAttribute("addRuleForm", addRuleForm);
return "listRules"; return "listRules";
} }
@GetMapping("addTerm")
public String addTerm(Model model) {
model.addAttribute("addTermForm", new AddTermForm());
return "addTerm";
}
@PostMapping("addTerm")
public String parse(@ModelAttribute AddTermForm addTermForm, Model model) {
model.addAttribute("addTermForm", addTermForm);
return "listTerms";
}
} }

View File

@ -0,0 +1,40 @@
package ru.ulstu.fc.rule.model;
public class AddTermForm {
private String variable;
private String term;
private String min;
private String max;
public String getVariable() {
return variable;
}
public void setVariable(String variable) {
this.variable = variable;
}
public String getTerm() {
return term;
}
public void setTerm(String term) {
this.term = term;
}
public String getMin() {
return min;
}
public void setMin(String min) {
this.min = min;
}
public String getMax() {
return max;
}
public void setMax(String max) {
this.max = max;
}
}

View File

@ -0,0 +1,41 @@
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml"
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">
<form action="/addTerm" th:object="${addTermForm}" method="post">
<div class="row">
<div class="col-md-2 col-sm-12">
<select id="select-variable" class="selectpicker m-2" data-live-search="true"
th:field="*{variable}"
data-width="90%">
<option th:each="var : ${variables}"
th:value="${var}"
th:utext="${var}">
</option>
</select>
</div>
<div class="col-md-2 col-sm-12">
<input class="form-control" type="text" th:field="*{term}">
</div>
<div class="col-md-2 col-sm-12">
<input class="form-control" type="text" th:field="*{min}">
</div>
<div class="col-md-2 col-sm-12">
<input class="form-control" type="text" th:field="*{max}">
</div>
</div>
<div class="row">
<div class="col-md-4 col-sm-12">
<input type="submit" class="btn btn-outline-success m-2" value="Создать term"/>
</div>
</div>
</form>
</div>
</html>