package com.mvc.controller.base; import java.text.SimpleDateFormat; import java.util.Date; import org.springframework.beans.propertyeditors.CustomDateEditor; import org.springframework.stereotype.Controller; import org.springframework.web.bind.ServletRequestDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import com.mvc.utils.StringEscapeEditor; @Controller @RequestMapping("/base") public class BaseController { protected int page = 1;// 当前页 protected int rows = 10;// 每页显示记录数 protected String sort;// 排序字段 protected String order = "asc";// asc/desc protected String ids;// 主键集合,逗号分割 @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)); } /** * 用户跳转JSP页面 * * 此方法不考虑权限控制 * * @param folder * 路径 * @param jspName * JSP名称(不加后缀) * @return 指定JSP页面 */ @RequestMapping("/{folder}/{jspName}") public String redirectJsp(@PathVariable String folder, @PathVariable String jspName) { return "/" + folder + "/" + jspName; } }
最近下载更多
qiaoxiansheng LV6
2023年8月8日
zhaoyangwfd LV17
2022年11月29日
1083912911 LV4
2022年4月18日
getset LV8
2022年3月25日
dchengl7300 LV3
2021年12月15日
wanglinddad LV54
2021年9月23日
1029162867 LV13
2021年6月7日
窗边的小豆豆 LV1
2021年5月7日
lizhoutao LV11
2020年12月11日
caochengbo LV6
2020年11月1日
最近浏览更多
educationAAA LV4
4月18日
荣》Cowboy LV12
4月11日
fff2003 LV6
2023年12月23日
WBelong LV7
2023年12月11日
fesfefe LV13
2023年10月20日
qiaoxiansheng LV6
2023年8月8日
dzlwindy LV8
2023年6月29日
1083912911 LV4
2023年6月28日
chenhs
2023年6月20日
暂无贡献等级
6389181 LV7
2023年6月1日