Reputation: 1
I am new to springs so help me out.... I need to know the web.xml configuration to filter all my request through a custom filter....
i.e
This is my normal web.xml
<servlet>
<servlet-name>controller</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>controller</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
now what changes should i make to my web.xml so that all my requests pass through custom filter... Thanks in advance.
Upvotes: 0
Views: 1825
Reputation: 279990
If you are talking about a javax.servlet.Filter
, the configuration is as follows in the web.xml
.
<filter>
<filter-name>custom-filter</filter-name>
<filter-class>your.filter.type.MyFilter</filter-class>
<!-- Other options -->
</filter>
<filter-mapping>
<filter-name>custom-filter</filter-name>
<url-pattern>/*</url-pattern>
<!-- Other options -->
</filter-mapping>
You can read all the configuration options here.
Upvotes: 2