package cn.reghao.tnb.search.esapp.blog.controller;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.ServletRequestDataBinder;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author reghao
 * @date 2023-04-18 09:55:42
 */
//@Controller
public 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(true, false));
    }
}
