I create a spring mvc project in IntelliJ 14, just did as http://www.tutorialspoint.com/spring/spring_web_mvc_framework.htm did.But appeared this issue:No mapping found for HTTP request with URI [/test/WEB-INF/jsp/hello.jsp] in DispatcherServlet with name 'HelloWeb'
I googled and found some links in stackoverflow but it didn`t help.My IDE is IntelliJ 14, Maven version is 3.1.1 and My Spring Framework version is 4.1.6.
This is my web.xml:
<servlet>
<servlet-name>HelloWeb</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloWeb</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
This is my HelloWeb-servlet.xml:
<context:component-scan base-package="com.tutorialspoint" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
This is my controller:
@Controller
@RequestMapping("/hello")
public class HelloController {
@RequestMapping(method = RequestMethod.GET)
public String printHello(ModelMap modelMap) {
modelMap.addAttribute("message", "Hello Spring MVC FrameWork!");
System.out.println("Hello, World!");
return "hello";
}
}
My hello.jsp was located : /web/WEB-INF/jsp/hello.jsp and its content is:
<html>
<head>
<title>Hello Spring MVC</title>
</head>
<body>
<h2>${message}</h2>
</body>
</html>
It is puzzling, I set a break point in printHello() method, when I input: http://localhost:8080/test/hello.jsp in browser, as a result it goes into the printHello() method and prints "Hello, World!", but doesn`t find the hello.jsp page.
This is the result when I input http://localhost:8080/test/hello.jsp in browser:
Hello, World!
六月 07, 2015 11:27:11 下午 org.springframework.web.servlet.PageNotFound noHandlerFound
警告: No mapping found for HTTP request with URI [/test/WEB-INF/jsp/hello.jsp] in DispatcherServlet with name 'HelloWeb'
It is very strange, any help will be appreciate.
Your project structure is probably wrong. See both paths:
they are different.