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())); //將評論信息插入數(shù)據(jù)庫 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
確認一下校驗規(guī)則是否滿足。錯誤日志如有有Exception
在控制臺或者localhost_access_xxxx.log
日志中都可以看到。
添加回答
舉報
0/150
提交
取消