0
在Spring Boot网络应用程序中,User
想重置他的密码,因此他输入Reset password
页面。现在我想让他键入他的电子邮件地址,按Reset
,我想重定向到myapp/resetPassword?email=HIS_EMAIL
以处理密码重置。请求参数与thymeleaf
我的代码:
@RequestMapping(value = "/resetPassword", method = RequestMethod.GET)
public String resetPasswordForm(Model model){
model.addAttribute("email", new String());
return "resetPassword";
}
@RequestMapping(value = "/resetPassword", method = RequestMethod.POST)
public String resetPassword(@RequestParam("email") String email) {
User user = userService.findUserByEmail(email);
//playing with logic
return "redirect:/";
}
我怎样才能实现呢我thymeleaf网页上?我试过这样的:
<form th:action="@{/resetPassword(email=${email})}" method="post">
<input type="email" th:field="${email}" th:placeholder="Email" />
<div class="clearfix">
<button type="submit">Reset</button>
</div>
</form>
不幸的是我的email
总是空。有人可以帮忙吗?
'错误400':'必需的字符串参数'电子邮件'不存在' – crooked
抱歉,我的错。我编辑了@RequestParam。现在它应该工作。 – benkuly
Yeaa,现在我明白了:)感谢您的帮助!顺便说一句。我的代码实际上很糟糕:) – crooked