开发者

Spring filters working flow

i am using spring mvc. for login whenever request comes it passes through various Filters to get the flow(a开发者_开发问答s different flow for different types of users). please suggest me a good reference to Spring Filters. or a good example on it. how to configure context.xml,web.xml


Do you need something other than the spring security docs ?

This is the page from the official docs related to filters.


Filters need to be configured in both the application context.xml and the web.xml file in your project. Here are examples of each of these files and also a Login filter that I wrote for my application... Hope it helps.

Web.xml

<filter> 
    <filter-name>randomFilter</filter-name> 
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
    <init-param> 
        <param-name>targetFilterLifecycle</param-name> 
        <param-value>true</param-value> 
    </init-param> 
</filter> 

Filter mappings also need to be specified in this file and the order in which these mappings occur decide which filter is called first.

<filter-mapping> 
    <filter-name>randomFilter</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

In the application context.xml, we mention the filter path, for example:

    <bean id="randomFilter" class="folderPath.RandomFilter"/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜