POST提交较短字符串时没问题,稍长字符串就显示400错误,修改tomcat的server.xml没用表单只有如下两个字段,这个content长度就会报错控制器代码//处理新闻评论表单提交@RequestMapping(value = "/news", method = RequestMethod.POST)public String doReplyNews(@Validated NewsReplyFormBean newsReplyFormBean, @RequestParam("newsId") int newsId, BindingResult bindingResult, Model model, HttpSession httpSession){ //表单校验出错 if(bindingResult.hasErrors()) { this.fillNewsPageContent(model, newsId); return "news"; } //表单校验成功 else { User user = (User)httpSession.getAttribute("user"); //Session登陆校验失败 if(user == null) { this.fillNewsPageContent(model, newsId); model.addAttribute("replyError", "请先登陆!"); return "news"; } //登陆校验成功 else { newsReplyFormBean.setContent(KeywordReplaceUtil.HTMLTageFilter(newsReplyFormBean.getContent())); //将评论信息插入数据库 userService.addNewsReply(newsReplyFormBean, (long)newsId, user.getUserId()); //组装重定向URL return "redirect:news?id=" + newsId; } }}velocity里的表单<form role="form" action="news" method="post" id="form" onsubmit="return check();"> <input type="text" class="sr-only" name="newsId" value="${news.newsId}" /> <div class="form-group"> <label class="control-label sr-only" for="content"></label> #springBind("newsReplyFormBean.content") <textarea name="content" class="form-control" id="content" placeholder="说点什么..."></textarea> <p class="help-block" style="color: red" id="reply_help"></p> <p class="help-block" style="color: red">$!{replyError}</p> </div> <input type="submit" value="提交" /></form>还有个问题,不知道应该怎样看到这类错误的错误日志
1 回答
qq_笑_17
TA贡献1818条经验 获得超7个赞
@Validated
确认一下校验规则是否满足。错误日志如有有Exception
在控制台或者localhost_access_xxxx.log
日志中都可以看到。
添加回答
举报
0/150
提交
取消