参考资料:
@RequestMapping(value = "/matches/{matchId}", produces = "application/json")
@ResponseBody
public String match(@PathVariable String matchId, @RequestBody String body,
HttpServletRequest request, HttpServletResponse response) {
String json = matchService.getMatchJson(matchId);
if (json == null) {
response.setStatus( HttpServletResponse.SC_BAD_REQUEST );
}
return json;
}
本文详细介绍了如何在Spring MVC中使用ResponseBody方法处理HTTP 400错误,并通过示例代码展示了具体实现过程。

被折叠的 条评论
为什么被折叠?



