標籤:sha ref cat classpath tty init div map freemark
轉自:
http://www.cnblogs.com/shanheyongmu/p/5684595.html
<!-- Velocity --><bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> <property name="order" value="0" /> <property name="contentType" value="text/html;charset=UTF-8" /> <property name="requestContextAttribute" value="req"/></bean> <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="configLocation" value="/WEB-INF/velocity.properties"/> <property name="resourceLoaderPath" value="/" /></bean><!-- FreeMarker --><bean id="freeMarkerViewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> <property name="order" value="0" /> <property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/> </bean> <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="configLocation" value="/WEB-INF/freemarker.properties"/> <property name="templateLoaderPath" value="/WEB-INF/ftl/"/> <property name="freemarkerVariables"> <map> <entry key="xml_escape" value-ref="fmXmlEscape"/> </map> </property></bean><bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape"/> <!-- Tiles--> <bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"></property> <property name="order" value="1" /></bean> <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"> <property name="definitions"> <list> <value>classpath:layout.xml</value> </list> </property></bean><!-- 定義JSP檔案的位置 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/pages/"/> <property name="suffix" value=".jsp"/> <property name="order" value="1" /></bean>
注意:
關鍵點 <property name="order" value="1" />配置 0,1,2,3,4,5,6......首先從0開始解析,依次往下,jsp的一定要放到最後,不然找到返回頁面直接返回到404頁面了,不會去其他頁面匹配了,或者吧jsp的order設定到最高,這是個坑,或者自己寫解析器進行解析。
springmvc配置多視圖 - tiles, velocity, freeMarker, jsp