Pregunta


I am trying to integrate Tiles into our current Spring MVC (Spring 2.5) based app and for the most part it's working fine with initial pages. We have close to 300 jsp pages and a new section of website which we are implementing via Tiles. I know I need to use ResourceBundleViewResolver along with view.properties file in order to mix up different View Technologies (JSTL/JSP and Tiles).
Seeing this approach, it seems like an overkill to use properties file, what I mean is I have to specifically mention the 300 or so JSP returns in this file along with the Tiles returns.
I am wondering if there is some sort of wildcard based approach, for example:
*.html = return all JSPs, *.ti = return all tiles
Any help to achieve something similar much appreciated. My current configuration is attached:

   <bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
        <property name="basename" value="views"/>
  </bean>

view.properties:

tilehome.class=org.springframework.web.servlet.view.tiles2.TilesView
tilehome.url=tilehome
login.class=org.springframework.web.servlet.view.JstlView
login.url=/WEB-INF/jsp/login.jsp
¿Fue útil?

Solución

you don't need to mention the jsp pages in view.properties

Instead also define a InternalResourceViewResolver as a fallback view resolver (with a higher order than your existing view resolver)

What will happen then is when a view is not found in your views.properties (ie. views that you want to resolve to jsps) it will then use the InternalResourceViewResolver to resolve the view.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top