When I'm looking at Spring FrameWork 3.0 I see the following code example:
@RequestMapping("/index.dlp")
public ModelAndView index(){
logger.info("Return View");
return new ModelAndView("index");
}
This option doesn't work for me. Only when I change the code the following way:
@RequestMapping("/index.dlp")
public ModelAndView index(){
logger.info("Return View");
return new ModelAndView("index.jsp");
}
It works fine. Can anybody tell me why?
What Is the Core Problem That Spring MVC Framework Solves? Spring MVC Framework provides decoupled way of developing web applications. With simple concepts like Dispatcher Servlet, ModelAndView and View Resolver, it makes it easy to develop web applications.
Class Phalcon\Mvc\Dispatcher Dispatching is the process of taking the request object, extracting the module name, controller name, action name, and optional parameters contained in it, and then instantiating a controller and calling an action of that controller.
In the case of Spring MVC, DispatcherServlet is the front controller. The DispatcherServlet's job is to send the request on to a Spring MVC controller. A controller is a Spring component that processes the request.
View names are resolved into the actual views by ViewResolver
s.
To refer JSP pages by short names, you need to supply InternalResourceViewResolver
with prefix
and suffix
. The following configuration maps index
to /WEB-INF/jsp/index.jsp
:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
See also:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With