I am trying to set up my Spring MVC testing environment.
But I always get this noHandlerFound error:
Aug 21, 2014 4:43:25 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/restful/firstPage] in DispatcherServlet with name 'spring'
Aug 21, 2014 4:47:21 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/restful/firstPage2] in DispatcherServlet with name 'spring'
Aug 21, 2014 5:10:27 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/restful/index.html] in DispatcherServlet with name 'spring'
I already searched for solution, but none can fix my problem.
My spring mvc version: 3.1.3.RELEASE
This is my web.xml:
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml
</param-value>
</context-param>
this is my spring-servlet.xml:
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
this is my applicationContext.xml:
<context:annotation-config />
<context:component-scan base-package="test.spring" />
<mvc:annotation-driven />
<mvc:resources mapping="/index.html" location="/index.html" />
<mvc:view-controller path="/firstPage" />
This is my Controller:
package test.spring;
....
@Controller
@RequestMapping("/")
public class FirstController {
@RequestMapping(value = "firstPage2", method = RequestMethod.GET)
public String showFirstPage(Map<String,Object> model){
return "firstPage";
}
}
My server is tomcat 7, there is no error and warning when it is deployed.
I also tried this with no luck:
<mvc:default-servlet-handler/>
Before I start Spring MVC, I can access index.html