filter过滤后css没起作用啊,图片也显示不了
web.xml配置
<filter>
<filter-name>logFilter</filter-name>
<filter-class>lee.LogFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
<init-param>
<param-name>loginPage</param-name>
<param-value>login.jsp</param-value>
</init-param>
<init-param>
<param-name>regPage</param-name>
<param-value>reg.jsp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>logFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
LogFilter.java
public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws
IOException,
ServletException{
String encoding=config.getInitParameter("encoding");
String loginPage=config.getInitParameter("loginPage");
String regPage=config.getInitParameter("regPage");
request.setCharacterEncoding(encoding);
response.setCharacterEncoding(encoding);
HttpServletRequest requ=(HttpServletRequest)request;
HttpSession session=requ.getSession(true);
String requestPath=requ.getServletPath();
if(session.getAttribute("username")==null && !requestPath.endsWith(loginPage) && !requestPath.endsWith(regPage)){
request.setAttribute("tip", "你还没有登录");
request.getRequestDispatcher(loginPage).forward(request, response);
}
chain.doFilter(request, response);
}
各位大侠帮帮忙要怎么改啊
------解决方案--------------------
filter 不要过滤文件信息,js,css,图片等,一般来讲都过滤jsp .do等
------解决方案--------------------
一定这么写。
<filter-name>logFilter</filter-name>
<url-pattern>/*.jsp</url-pattern>
</filter-mapping>