@CrossOrigin(origins = "*", maxAge = 3600) public abstract class BaseController { @InitBinder public void initBinder(ServletRequestDataBinder binder) { // 自动转换日期类型的字段格式 binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), true)); // 防止XSS攻击 binder.registerCustomEditor(String.class, new StringEscapeEditor()); } }
原文地址:http://15129824665.blog.51cto.com/10510385/1979705