How to use multiple places in Spring viewresolver?

*爱你&永不变心* 提交于 2020-01-06 10:54:05

问题


this is how I define the loaction of my jsp files:

<bean id="jspViewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView" />
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
</bean>

But I have too many JSP files in one folder at the moment...I changed my directiory structure to this:

/WEB-INF/jsp/city/*.jsp
/WEB-INF/jsp/weather/*.jsp

How must I change my viewresolver so that both places are found?

Ask for more info if needed.


回答1:


Don't change it at all, just return qualified view names, e.g.

"city/tokyo" or "weather/partlyCloudy"




回答2:


I'm sure the Sean Patrick Floyd answer is a better way to do this, but if you are not willing to use that technique, define two view resolvers, one with the prefix "/WEB-INF/jsp/city" and the other with the prefix "/WEB-INF/jsp/weather".



来源:https://stackoverflow.com/questions/7527607/how-to-use-multiple-places-in-spring-viewresolver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!