1、Spring当你的控制层方法抛出异常的情况下,抛出异常会统一调用如下方法。
@ExceptionHandler
public @ResponseBody String handle(Exception e) {
logger.error("", e);
JSONObject obj = new JSONObject();
obj.put("success",true);
obj.put("result","error");
obj.put("info",e.getMessage());
return obj.toString();
}
2、当前台form表单提交时会,会映射自动映射form中,但遇到是Data类型的数据,它会自动通过下列方法自动转换
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}