Spring 3.0: Handler mapping issue

Posted by Yaniv Cohen on Stack Overflow See other posts from Stack Overflow or by Yaniv Cohen
Published on 2010-03-15T16:20:24Z Indexed on 2010/03/16 19:21 UTC
Read the original article Hit count: 443

I am having a trouble mapping a specific URL request to one of the controllers in my project.

the URL is : http://HOSTNAME/api/v1/profiles.json the war which is deployed is: api.war

the error I get is the following:

[PageNotFound] No mapping found for HTTP request with URI [/api/v1/profiles.json] in DispatcherServlet with name 'action'

The configuration I have is the following: web.xml :

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext.xml,/WEB-INF/applicationContext-security.xml</param-value>
 </context-param>

 <!-- Cache Control filter -->
 <filter>
  <filter-name>cacheControlFilter</filter-name>
  <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
 </filter>

 <!-- Cache Control filter mapping -->
 <filter-mapping>
  <filter-name>cacheControlFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

 <!-- Spring security filter -->
 <filter>
  <filter-name>springSecurityFilterChain</filter-name>
  <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
 </filter>

 <!-- Spring security filter mapping -->
 <filter-mapping>
  <filter-name>springSecurityFilterChain</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

 <!-- Spring listener -->
 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>

 <!-- Spring Controller -->
 <servlet>
  <servlet-name>action</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>

 <servlet-mapping>
  <servlet-name>action</servlet-name>
  <url-pattern>/v1/*</url-pattern>
 </servlet-mapping> 

The action-servlet.xml:

<mvc:annotation-driven/>    

<bean id="contentNegotiatingViewResolver"
  class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
  <property name="favorPathExtension" value="true" />
  <property name="favorParameter" value="true" />
  <!--
   default media format parameter name is 'format'
  -->
  <property name="ignoreAcceptHeader" value="false" />
  <property name="order" value="1" />
  <property name="mediaTypes">
      <map>
        <entry key="html" value="text/html"/> 
        <entry key="json" value="application/json" />
        <entry key="xml"  value="application/xml" /> 
      </map>
  </property>  
  <property name="viewResolvers">
      <list>        
        <bean  class="org.springframework.web.servlet.view.InternalResourceViewResolver">
          <property name="prefix" value="/WEB-INF/jsp/"/>
          <property name="suffix" value=".jsp"/>
          <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
        </bean>
      </list>
  </property>  
  <property name="defaultViews">
      <list>              
        <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
        <bean class="org.springframework.web.servlet.view.xml.MarshallingView">
          <constructor-arg>
            <bean class="org.springframework.oxm.xstream.XStreamMarshaller" />
          </constructor-arg>
        </bean>        
      </list>
  </property>
 </bean>

the application context security:

<sec:http auto-config='true'  >
  <sec:intercept-url pattern="/login.*"      filters="none"/> 
  <sec:intercept-url pattern="/oauth/**"       access="ROLE_USER" />
  <sec:intercept-url pattern="/v1/**"       access="ROLE_USER" />
  <sec:intercept-url pattern="/request_token_authorized.jsp"  access="ROLE_USER" />
  <sec:intercept-url pattern="/**"        access="ROLE_USER"/>
  <sec:form-login authentication-failure-url ="/login.html"
      default-target-url   ="/login.html" 
      login-page     ="/login.html"
      login-processing-url  ="/login.html" />

  <sec:logout logout-success-url="/index.html" logout-url="/logout.html" />
 </sec:http>

the controller:

@Controller
public class ProfilesController {

 @RequestMapping(value = {"/v1/profiles"}, method = {RequestMethod.GET,RequestMethod.POST})
 public void getProfilesList(@ModelAttribute("response") Response response) {
  ....
 }

}

the request never reaches this controller.

Any ideas?

© Stack Overflow or respective owner

Related posts about spring-mvc

Related posts about spring-framework