Thursday, January 17, 2008

spring ViewResolver

spring's dispatcher servlet delegates to a ViewResolver to map returned view names to view implementations. by default, view names are treated as web application relative file paths, but this can be overridden by registering a ViewResolver bean within the application context.

by using the following code, view names will be prefixed with '/WEB-INF/views' and suffixed with '.jsp':

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views"/>
<property name="suffix" value=".jsp"/>
this means if a ModelAndView is returned from a Controller with a view name 'summary', the resource '/WEB-INF/views/summary.jsp' will be returned.


Post a Comment

Links to this post:

Create a Link

<< Home