Мой контроллер:
@Controller
public class MainController {
@GetMapping("/")
public String mainPage() {
return "main";
}
@RequestMapping(value = "/", params = {"addRow"})
public String addRow(ModelForCheck modelForCheck, BindingResult bindingResult) {
modelForCheck.getVariables().add(new Variable());
return "main";
}
}
Мой класс модели, который я использовал для проверки моего кода:
public class ModelForCheck {
private List<Variable> variables = new ArrayList<>();
public List<Variable> getVariables() {
return variables;
}
public void setVariables(List<Variable> variables) {
this.variables = variables;
}
}
Мой класс модели:
public class Variable {
private String name;
private String type;
public Variable() {
}
public Variable(String name, String type) {
this.name = name;
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
Мой html страница (главная. html):
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Hello!</title>
</head>
<body>
<form th:action="@{/}" method="post">
<h3>Variables:</h3>
<button type="submit" name="addRow">Add Row</button>
<table>
<tr th:each="variable, variableStat : *{variables}">
<td><input type="text" th:field="*{variables[__${variableStat.index}__].name}" placeholder="name"></td>
<td><input type="text" th:field="*{variables[__${variableStat.index}__].type}" placeholder="type..."></td>
</tr>
</table>
<br>
<input type="submit" value="Generate!">
</form>
</body>
</html>
введите описание изображения здесь
Я нажимаю кнопку «Добавить строку», но по какой-то причине нет никакой реакции со стороны приложения. В журналах нет ни сообщений об ошибках, ни других сообщений. Я точно знаю, что запущен метод addRow, так как я проверял его в отладке