Results 1 to 2 of 2

Thread: J2EE filter and Spring MVC controllers, can they be used together?

  1. #1

    Default J2EE filter and Spring MVC controllers, can they be used together?

    Requests sent to my Spring MVC system are being processed by a J2EE filter but never making it to the Spring controllers. Can these two components be used together or do I need to use DelegatingProxyFilter to allow filtered requests to make it to the controllers. Or is this just a symptom of a URL mapping problem?

    From my web.xml:
    Code:
        <servlet-mapping>
            <servlet-name>dbconnect</servlet-name>
            <url-pattern>/dbconnect/DBconnect</url-pattern>
        </servlet-mapping>
        
        <!-- filter that adds the command and, optionally, the subcommand as an attribute of the servlet request -->
        <filter>
            <filter-name>CommandFilter</filter-name>
            <filter-class>com.mycompany.dbconnect.filter.CommandFilter</filter-class>
            <description>
                Adds command[subcommand] as an attribute of the request object
            </description>
        </filter>
        
        <!-- the command filter needs to see every incoming request -->
    	<filter-mapping>
        	<filter-name>CommandFilter</filter-name>
        	<url-pattern>/*</url-pattern>
     	</filter-mapping>

    Thanks for any help or advice,
    bils

  2. #2

    Default

    It's me answering my own question here. The short answer is yes. (obviously) J2EE filters and Spring MVC play nice together, no problem using them both in an application. DelegatingProxyFilter is useful of you need a filter that has access to the spring IOC.

    In case you are interested, my problem turned out to be an incorrect <context:component-scan base-package=...> when the package name of the controllers was changed.

    Hope this helps future J2EE + Spring MVC users.

    bills.

Posting Permissions

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