猿问

配置拦截器后JSP页面找不到引用的javascript

拦截器配置成功后原jsp页面引用的js404了
js引用如下

 <script type='text/javascript' src='<%=basePath%>admin/js/aclock.js'></script>
    <script type="text/javascript" src="<%=basePath%>admin/eventJS/sharingJS.js"></script>

web.xml如下:

 <filter>
        <filter-name>Login</filter-name>
        <filter-class>com.xxxx.Util.LoginFilter</filter-class>
        </filter>
    <filter-mapping>
        <filter-name>Login</filter-name>
        <url-pattern>/admin/*</url-pattern>
        <url-pattern>/views/*</url-pattern>
    </filter-mapping>
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/js/*</url-pattern>
        <url-pattern>/css/*</url-pattern>
        <url-pattern>/images/*</url-pattern>
    </servlet-mapping>

拦截器如下:

 public void doFilter(ServletRequest arg0, ServletResponse arg1,
            FilterChain arg2) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) arg0;
        HttpServletResponse resp = (HttpServletResponse) arg1;
        HttpSession session = req.getSession();
        String path = req.getRequestURI();
        System.out.println(path);
        String admin_account = (String) session.getAttribute("admin_account");
     if(path.indexOf("image.jsp") > -1){
             arg2.doFilter(req, resp);
             return;
         }else {// 如果不是login.jsp进行过滤
             if (admin_account == null || "".equals(admin_account)) {
                    resp.sendRedirect("/stone-bi/index.jsp");
                } else {
                    // 已经登陆,继续此次请求
                    arg2.doFilter(req, resp);
                }
         }
    }


海绵宝宝撒
浏览 535回答 3
3回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答