struts2中怎样实现过滤jsp页面的过滤器
1个回答
展开全部
如下所示:
package test;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class LoginFilter implements Filter
{
public void destroy()
{
}
public void doFilter(ServletRequest req, ServletResponse rsp,
FilterChain chain) throws IOException, ServletException
{
chain.doFilter(req, rsp);
}
public void init(FilterConfig arg0) throws ServletException
{
}
}
在web.xml里面配置
<filter>
<filter-name>logFilter</filter-name>
<filter-class>test.LoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>logFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
package test;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class LoginFilter implements Filter
{
public void destroy()
{
}
public void doFilter(ServletRequest req, ServletResponse rsp,
FilterChain chain) throws IOException, ServletException
{
chain.doFilter(req, rsp);
}
public void init(FilterConfig arg0) throws ServletException
{
}
}
在web.xml里面配置
<filter>
<filter-name>logFilter</filter-name>
<filter-class>test.LoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>logFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
Storm代理
2023-08-29 广告
2023-08-29 广告
StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,IP...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询