Ok so I have encountered the fairly common errror:
WARNING: No mapping found for HTTP request with URI [/WEB-INF/jsp/index.jsp] in DispatcherServlet with name 'app'
I'm looking at the existing answers and I've not seen a really good explanation of how the components interact. Seeing as I can't solve my issue based on the existing answers, I'm hoping someone can provide a detailed explanation of the function of DispatcherServlet
and Resolver
s.
Developing in Eclipse, I have the following structure:
/src/com/whiuk/philip/web/controller/IndexController.java
/WebContent
/WebContent/WEB-INF
/WebContent/WEB-INF/web.xml
/WebContent/WEB-INF/app-servlet.xml
/WebContent/WEB-INF/jsp/index.jsp
Eclipse Deployment Assembly means it deploys as follows:
/src -> WEB-INF/classes
/WebContent -> /
/ivy.xml[*] -> WEB-INF/lib
I have a web.xml file that defines a DispatcherServlet
and a mapping to all files (/*
)
<servlet>
<servlet-name>app</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>app</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
I have a app-servlet.xml file that scans the packages and defines a InternalResourceViewResolver
:
<context:component-scan base-package="com.whiuk.philip.web" />
<mvc:annotation-driven />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
I have a IndexController
that has a RequestMapping for index:
@Controller
public class IndexController {
@RequestMapping(value = "/index", method = RequestMethod.GET)
public ModelAndView index() {
return new ModelAndView();
}
}
Logs show this is registered:
org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/index],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}"
onto public org.springframework.web.servlet.ModelAndView
com.whiuk.philip.web.controller.IndexController.index()
Finally I have a index.jsp file.
Can someone please explain what the misconfiguration is that results in the error shown at the top and, if possible, provide a sentence or so on the purpose of DispatcherServlet, Resolvers and how they feed into Controllers.