【问题标题】:Spring Boot GET function not called in controller控制器中未调用 Spring Boot GET 函数
【发布时间】:2018-06-08 09:36:42
【问题描述】:

我想使用表单验证重置密码输入。我将 Spring Boot 与 Hibernate 和 Thymeleaf 一起使用。

问题:HTML 表单 POST 函数不调用 Spring POST 控制器。 我尝试通过添加记录器来测试它,但它们不会被调用。 当我输入新密码并提交时,页面会自动返回登录页面。

HTML:

<body class="login login-background">
<div id="wrap">
    <div id="main" class="container clear-top">
        <div class="container">
            <div class="row">
                <div class="col-md-4 col-md-offset-4">
                    <form th:action="@{/resetPassword}"
                          th:object="${resetPasswordForm}" method="POST">
                        <input id="password" type="password"/>
                        <input type="hidden" th:name="${_csrf.parameterName}"
                               th:value="${_csrf.token}"/>
                        <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in
                        </button>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
</body>

我已经尝试了 2 天来查找问题,但我似乎无法弄清楚。我希望有人可以帮助我。谢谢!

【问题讨论】:

    标签: spring hibernate spring-boot thymeleaf


    【解决方案1】:

    您的表单操作网址是 /resetPassword,但您的控制器帖子网址是 /reset

    【讨论】:

      猜你喜欢
      • 2018-11-24
      • 2019-02-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-02
      • 2020-11-09
      • 1970-01-01
      • 1970-01-01
      • 2017-03-22
      相关资源
      最近更新 更多