Using Spring webflow and in the serlvet-configuration I have this for JSP files:
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
and this for flow XML files:
<webflow:flow-registry id="flowRegistry"
flow-builder-services="flowBuilderServices">
<webflow:flow-location-pattern value="/WEB-INF/flows/**/*-flow.xml" />
</webflow:flow-registry>
Due to the /**/
, any flow XML file in may they be in sub directory or not is resolved automatically so I need not specify the subfolder in the flow definition. For JSP **
does seem not work.
Is there a way to do the same? I'd like to use subdirectories, because it makes it look cleaner when don't have to scroll through a heap of JSP files in the package explorer. On the other hand, If I have to specify the subdirectory each time, it's probably prone to getting typos not being detected
I don't think there is a way to specify ant style wildcard in 'prefix' or 'suffix' attribute.
As you said, you can specify the path in the flow definition as below
<view-state id="showSearchCriteria" view="customer/search">
<transition on="lookupCriteriaEntered" to="searchCustomer" />
</view-state>
Though not an elegant solution but you can try jsps in multiple subfolders of jsp folder using tiles as:
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tilesDef.xml</value>
</list>
</property>
</bean>
Define your tilesDef.xml as:
<tiles-definitions>
<definition name="page1" template="/WEB-INF/jsp/subFolder1/page1.jsp"/>
<definition name="page2" template="/WEB-INF/jsp/subFolder2/page2.jsp"/>
</tiles-definitions>
In your controller return as:
new ModelAndView("page1");
or as:
new ModelAndView("page2");
But the drawback of this would be that you cannot have 2 jsps with same name in different folders as the definition name is unique.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.