• 主页
  • 无法使用th:object在Spring Boot中加载页面

无法使用th:object在Spring Boot中加载页面

它包含一行错误:“在模板解析过程中发生错误(模板:"class path resource templates//register.html")”。我无法打开注册html页面将新对象添加到数据库中。为什么?

<form th:action="@{/register-user}" th:object="user" method="post">
        <div class="form-group">
            <label for="email">Email:</label>
            <input type="email" class="form-control" id="email" placeholder="Enter email" name="email">
        </div>
        <div class="form-group">
            <label for="password">Password:</label>
            <input type="password" class="form-control" id="password" placeholder="Enter password" name="pswd">
        </div>
        <div class="form-group form-check">
        </div>
        <button type="submit" class="btn btn-primary">Register</button>
    </form>

我的控制器

@RequestMapping(path="/register-user", method = RequestMethod.POST)
    public String registerNewUser(@Valid @ModelAttribute("user") User user){
        userService.register(user);
        return "redirect:/login";
    }

转载请注明出处:http://www.jxbyjx.net/article/20230516/1521342.html