如何将过滤器映射到JSP?我想在第一次调用JSP时首先调用过滤器,然后将请求发送到JSP。我该怎么做?
<filter>
<filter-name>Filter-1</filter-name>
<filter-class>Filters.Filter_1</filter-class>
</filter>
<filter-mapping>
<filter-name>Filter-1</filter-name>
<!-- map the filter to jsp . How do I do that ?-->
</filter-mapping>
答案 0 :(得分:2)
添加唯一标识特定JSP调用的URL模式
<filter-name>Filter-1</filter-name>
<url-pattern>YourJsp.jsp</url-pattern>
答案 1 :(得分:0)
<filter-mapping>
<filter-name>Filter-1</filter-name>
<servlet-name>your-Servlet-Name</servlet-name>
</filter-mapping>
我们可以完成所有JSP:
<url-pattern>*.jsp</url-pattern>