拦截器配置成功后原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); } } }
相关分类