为什么我不能送模特? Spring Boot 2 - Thymeleaf

问题描述 投票:1回答:1

我无法打开注册页面。如果我删除th:显示字段页面。我该如何解决问题。我不会说英语,谢谢...

错误

 Whitelabel Error Page
    This application has no explicit mapping for /error, so you are seeing this as a fallback.
    Thu Mar 01 01:10:34 EET 2018
    There was an unexpected error (type=Internal Server Error, status=500).
    An error happened during template parsing (template: "class path resource [templates/register.html]")

例外

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/register.html]")

注册HTML

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h3>Register</h3>
<form th:action="@{register}" method="post" th:object="${user}">

<input type="text"  th:field="*{username}">
<input type="text"  th:field="*{password}">
<input type="submit" value="Submit">
</form>
 </body>
</html>

调节器

@Controller
@RequestMapping("/")
public class UserController {

    @RequestMapping(value="", method=RequestMethod.GET)
    public String getHomePage()
    {
        return "home";
    }

    @RequestMapping(value="register",method=RequestMethod.GET)
    public String getRegisterPage(Model model)
    {
        model.addAttribute("user",new User());
        return "register";
    }

}
java spring-boot web thymeleaf
1个回答
0
投票

关闭所有输入标签并尝试th:action="@{/register}"

© www.soinside.com 2019 - 2024. All rights reserved.