Thymeleaf + Spring Boot. Я пытаюсь сделать динамические поля, но при нажатии кнопки вообще ничего не происходит

@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;
    }
}
<!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>

введите сюда описание изображения

Нажимаю на кнопку "Add Row", но почему-то вообще нет никакой реакции со стороны приложения. В логах нет ни сообщений об ошибке, ни каких-либо других сообщений. Точно знаю, что метод "addRow" запускается, так как проверил это в дебаге


Ответы (0 шт):