Simplist case my controller returns new ModelAndView("hello"). "hello" maps/resolves to (in an xml file) to a jsp, e.g. "hello" may map to WEB-INF/myapp/goodbye.jsp. I would like to write a test for my controller to verify the view name being returned will properly resolve to something. In the event that somewhere, either in the controller or the (I am using tiles to map) spring config that defines the mapping that the view name has not been fat fingered.
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/springmvc/tiles-myapp.xml</value>
</list>
</property>
</bean>
<definition name="hello" extends="main">
<put-attribute name="title" value="Simple App"/>
<put-attribute name="body" value="/WEB-INF/myapp/goodbye.jsp"/>
</definition>
You can use the Spring MVC Test Framework to verify the target JSP for a resolved view.
Here's a pertinent excerpt from the reference manual:
The
JavaConfigTests
in Spring's own test suite demonstrate such a test with JSPs and Tiles:Regards,
Sam