Results 1 to 3 of 3

Thread: selective request interceptor by URL

  1. #1
    Join Date
    Sep 2004
    Location
    Toulouse, France
    Posts
    50

    Default selective request interceptor by URL

    I'd like to write an interceptor that checks if the user is logged in, but only apply it (declaratively if possible) to certain URLs.

    e.g. if the user enters /login.action the interceptor is not applied, but if he enters /search.action it is.

    The method described in the documentation applies the interceptor to all requests independent of the URL.

    What's the best way of going about this?
    Best regards,
    Assaf

  2. #2
    Join Date
    Aug 2004
    Location
    London, UK
    Posts
    339

    Default

    You could use a different handler mapping strategy...

    Code:
    <beans>
        <bean id="handlerMapping" 
              class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">            
            <property name="interceptors">
                <list>
                    <ref bean="myInterceptor"/>
                </list>
            </property>
            <property name="mappings">
                <props>
                    <prop key="/search.action">myController</prop>
                </props>
            </property>
        </bean>
    
        <bean id="handlerMapping2" 
        class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">            
            <property name="mappings">
                <props>
                    <prop key="/login.action">myController</prop>
                </props>
            </property>
        </bean>
        
        <bean id="myInterceptor" class="com.foo.bar.Interceptor"/>    
    <beans>
    Regards,
    Darren Davison.
    Public Key: 0xE855B3EA

  3. #3
    Join Date
    Sep 2004
    Location
    Toulouse, France
    Posts
    50

    Default

    I should have guessed as much! Thanks!

    - Assaf

Similar Threads

  1. OpenSessionInView and portlet support
    By garpinc2 in forum Web Flow
    Replies: 31
    Last Post: Apr 9th, 2010, 11:12 AM
  2. Replies: 17
    Last Post: Jan 2nd, 2007, 01:43 PM
  3. Hibernate Long Session Per Flow?
    By akw in forum Web Flow
    Replies: 21
    Last Post: Dec 12th, 2005, 08:06 PM
  4. Replies: 9
    Last Post: Nov 1st, 2005, 10:36 PM
  5. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •