@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()); } }
时间: 2024-10-29 11:08:11