问题原因:在 @Valid
的那个参数后面紧跟着一个 BindingResult
的参数(一定要紧跟着)
参考来源:https://segmentfault.com/q/1010000008384686
正确的参数签名
@PostMapping("publishPost.do") public String publishPost(@Valid @ModelAttribute Post post, BindingResult bindingResult, Errors errors, Model model, Integer tid,String action, RedirectAttributes attributes) {
错误的签名
//发帖 @PostMapping("publishPost.do") public String publishPost(@Valid @ModelAttribute Post post,Integer tid, BindingResult bindingResult, Errors errors, Model model, String action, RedirectAttributes attributes) {