请教大家:
我写了个filter,内容如下:
public class LimitFilter implements Filter { private FilterConfig config;
public void destroy() {
this.config = null;
}
public void init(FilterConfig config) throws ServletException {
this.config = config;
}
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {
System.out.println("------begin--------");
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
chain.doFilter(request, response);
}
web.xml关键部分如下:
<filter>
<filter-name>limitFilter</filter-name>
<filter-class>com.chinawidth.card.filter.LimitFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>limitFilter</filter-name>
<url-pattern>/login.action</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
index.jsp页面:
<%
response.sendRedirect("login.action");
%>
程序运行,没有打印出:------begin--------
如果把<url-pattern>/login.action</url-pattern>改为:<url-pattern>/*</url-pattern>就有打印出
请问只针对login.action如何让该filter被调用?
我写了个filter,内容如下:
public class LimitFilter implements Filter { private FilterConfig config;
public void destroy() {
this.config = null;
}
public void init(FilterConfig config) throws ServletException {
this.config = config;
}
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {
System.out.println("------begin--------");
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
chain.doFilter(request, response);
}
web.xml关键部分如下:
<filter>
<filter-name>limitFilter</filter-name>
<filter-class>com.chinawidth.card.filter.LimitFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>limitFilter</filter-name>
<url-pattern>/login.action</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
index.jsp页面:
<%
response.sendRedirect("login.action");
%>
程序运行,没有打印出:------begin--------
如果把<url-pattern>/login.action</url-pattern>改为:<url-pattern>/*</url-pattern>就有打印出
请问只针对login.action如何让该filter被调用?
解决方案 »
- 网页视频播放 64位操作系统 chrome、firefox插件下载错误
- jsp可以用include指令吗?
- 高分求助:两个页面有时候无法输入中文,求高手...如何调试?[
- 大量数据写入xml
- hibernate-memcache 加载时提示错误,请高手帮忙,急!!!!!!!
- 中文乱码问题
- jsp怎样将自己的数据对象传说到php页面
- [电脑]的JSP,这里谁会啊,我紧急求助,是紧急求助啊
- 请教:怎样查看JSP编译生成的JAVA文件?
- 如果某些业务处理不符合规范,提交返回失败,但是原来填入的信息没有了,怎么解决这个问题
- java联接sql server一段时间后自动丢失联接
- tomcat?mysql?数据库操作类?问题在哪
http://localhost:6220/card/login.action在index.jsp里:
<%
response.sendRedirect("login.action");
%>
我url输入:http://localhost:6220/card,将转向login.action。url为:http://localhost:6220/card/login.action。如果我改成:
<%
request.getRequestDispatcher("login.action").forward(request,response);
%>
就报404找不到该action错误。换成:/login.action也不行。
期待告诉解决问题!观望!
<%
response.sendRedirect("login.action");
%>
用submit去试一下
<form action="/login.action" method="post"> <input type="submit" name="submit" value="提交" >
</form>如果,可以那是请求转发路径有问题..
应该是
response.sendRedirect("http://localhost:6220/card/login.do"); 吧。