maven - Spring mvc @RequestMapping on class level and method level 404 Status -


i know there lot of posts here same problem, none of them seem me, duplicate.

im creating spring mvc application using maven, have 1 controller 1 method. when put request mapping annotation on class level application works fine when put on class level , method level , send request this:

localhost:8080/myapplication/planification/projet

i 404 error: http status 404 - /myapplication/planification/web-inf/pages/test.jsp

here controller

@controller @requestmapping("/planification") public class planificationcontroller {   @requestmapping("/projet")  public modelandview projets (modelandview m){      m.addobject("projets", "all projects");     m.setviewname("test");      return m;  }  } 

mvc-dispatcher-servlet.xml

<beans>   <context:component-scan base-package="com.smit"/>   <mvc:annotation-driven/>   <!-- **** view resolver bean **** -->   <bean id="viewresolver"     class="org.springframework.web.servlet.view.internalresourceviewresolver">     <property name="prefix">         <value>web-inf/pages/</value>   </property>    <property name="suffix">         <value>.jsp</value>   </property>   </bean>  </beans> 

web.xml

<web-app> <servlet>     <servlet-name>mvc-dispatcher</servlet-name>     <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-    class> </servlet>  <servlet-mapping>     <servlet-name>mvc-dispatcher</servlet-name>     <url-pattern>/</url-pattern> </servlet-mapping>  <listener>     <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <context-param>     <param-name>contextconfiglocation</param-name>     <param-value>          /web-inf/mvc-dispatcher-servlet.xml      </param-value> </context-param> </web-app> 

hold on, using / in front of requestmapping value, means root. should removed this

 @requestmapping("projet") 

then go localhost:8080/myapplication/planification/projet

edit:

web-inf should have / in front!


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo