zhuguifei
2026-03-10 58402bd5e762361363a0f7d7907153c77dbb819f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.shlanbao.tzsc.base.controller;
 
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import org.apache.log4j.Logger;
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.shlanbao.tzsc.base.editor.TimeStampPropertyEditor;
import com.shlanbao.tzsc.base.interceptor.WorkOrderStatChangeInterceptor;
import com.shlanbao.tzsc.pms.sch.workorder.beans.MesMdMatBean;
import com.shlanbao.tzsc.pms.sch.workorder.beans.MesWorkOrderBean;
import com.shlanbao.tzsc.utils.extents.StringEscapeEditor;
 
/**
 * 基础控制器<br>
 * 其他控制器继承此控制器获得日期字段类型转换和防止XSS攻击的功能<br>
 * @author  Leejean
 */
@Controller
@RequestMapping("/baseController")
public class BaseController {
    protected Logger log = Logger.getLogger(this.getClass());
    protected String message="程序异常,请稍后再试.";
    protected Long infoId;//消息id
    @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));
        
        //自动转换timestamp类型的字段格式
        binder.registerCustomEditor(Timestamp.class, new TimeStampPropertyEditor("yyyy-MM-dd HH:mm:ss"));
    }
 
    /**
     * 用户跳转JSP页面
     * 
     * 此方法不考虑权限控制
     * 
     * @param folder
     *            路径
     * @param jspName
     *            JSP名称(不加后缀)
     * @return 指定JSP页面
     */
    @RequestMapping("/{folder}/{jspName}")
    public String redirectJsp(@PathVariable String folder, @PathVariable String jspName) {
        return "/" + folder + "/" + jspName;
    }
 
    public String getMessage() {
        return message;
    }
 
    public void setMessage(String message) {
        this.message = message;
    }
    
    
}