:私はHTTPのために持っている何変更春MissingServletRequestPartExceptionメッセージ
@RequestMapping("/upload")
public @ResponseBody String upload(@RequestParam("file") MultipartFile file){...}
/1.1 404見つからない:私は変更したい
{"timestamp":1462064481371,"status":404,"error":"Not Found",
"exception":"org.springframework.web.multipart.support.MissingServletRequestPartException",
"message":"Required request part 'file' is not present","path":"/upload"}
「必要な要求部 『ファイルは』存在しない」のようなもののために「パラメータが欠落している
012。注釈でこれを簡単に行う方法はありますか?
可能であれば、私は例外情報も抑制したいと思います。
ありがとうございます。
@ExceptionHandler(MissingServletRequestPartException.class)
public @ResponseBody Map<String,String> handleMissingServletRequestPartException(Exception exception, HttpServletResponse response) {
Map<String,String> errorMap = new HashMap<String,String>();
errorMap.put("message","missing parameter");
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
return errorMap;
}
...
{ "メッセージ": "欠落しているパラメータ"}