Jaanus
Jaanus

Reputation: 16541

How to use multiple places in Spring viewresolver?

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.

Upvotes: 0

Views: 6253

Answers (2)

DwB
DwB

Reputation: 38320

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".

Upvotes: 1

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 299048

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

"city/tokyo" or "weather/partlyCloudy"

Upvotes: 8

Related Questions