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
package com.shlanbao.tzsc.base.controller;
 
import java.io.PrintWriter;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
 
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
 
import com.shlanbao.tzsc.base.model.SessionInfo;
 
public class VerInterceptor implements HandlerInterceptor{
 
 
 
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
            Object arg2) throws Exception {
        HttpSession session=request.getSession();
        //验证后端登录
        SessionInfo userInfo=(SessionInfo)session.getAttribute("sessionInfo");
        System.out.println(request.getLocalPort()+"/"+ request.getLocalAddr()+"/"+request.getContextPath()+ "进入拦截器...");
        if(userInfo!=null){
            return true;
        }
        String path=request.getServletPath();
        System.out.println(path);
        if( "/pms/sysUser/login.do".equals(path) ){
            return true;
        }else if(path.contains("board")){ //大屏界面不攔截
            return true;
        } else if("/pms/workorder/sendOrderStatusMsg.do".equals(path)){
            return true;
        }else if("/pms/isp/board.do".equals(path)||"/pms/board/weekeffe.do".equals(path)
                ||"/pms/board/workorder.do".equals(path)||"/pms/board/monthqty.do".equals(path)
                ||"/pms/board/weekqty.do".equals(path)){
            return true;
        }
 
        String str=request.getScheme()+"://"+request.getLocalAddr()+":"+request.getLocalPort()+""+request.getContextPath()+"/pms";
        System.out.println("重定向地址:"+str+"/");
 
        //失败重定向
       PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<script>");
        out.println("window.open ('"+str+"','_top')");
        out.println("</script>");
        out.println("</html>");
        return false;
    }
 
    @Override
    public void afterCompletion(HttpServletRequest arg0,
            HttpServletResponse arg1, Object arg2, Exception arg3)
            throws Exception {
        // TODO Auto-generated method stub
 
    }
 
    @Override
    public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1,
            Object arg2, ModelAndView arg3) throws Exception {
        // TODO Auto-generated method stub
 
    }
 
 
}