ajax返回值中如果有中文,会出现乱码,解决方案:
@RequestMapping(value="/release", method=RequestMethod.POST)
public @ResponseBody ResponseEntity<String> release(Comment comment, @RequestParam("userId") String userId){
commentService.publish(comment,userId);
PageModel<LessonCommentVo> pageModel = this.getCommentData(comment.getLessonId());
String commentHTML = this.getCommentHTML(pageModel);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(new MediaType("text","html",Charset.forName("UTF-8")));
return new ResponseEntity<String>(commentHTML, responseHeaders, HttpStatus.OK);
}
返回值类型不能直接使用String ,要使用ResponseEntity<String>包装