コード例 #1
0
 /** indicates a missing parameter. */
 @ExceptionHandler(MissingServletRequestParameterException.class)
 public ResponseEntity<Map<String, Object>> handleMissingServletRequestParameterException(
     MissingServletRequestParameterException error) {
   Map<String, Object> errorMap = new HashMap<String, Object>();
   errorMap.put("hasErrors", "true");
   errorMap.put(
       "developerMessage",
       "the request parameter ["
           + error.getParameterName()
           + "] of type ["
           + error.getParameterType()
           + "]is missing");
   errorMap.put("userMessage", "please provide all the values");
   errorMap.put("moreInfo", error.getMessage());
   errorMap.put("errorCode", HttpStatus.BAD_REQUEST);
   error.printStackTrace();
   return new ResponseEntity<Map<String, Object>>(errorMap, HttpStatus.BAD_REQUEST);
 }