码迷,mamicode.com
首页 > 编程语言 > 详细

springmvc配置多视图 - tiles, velocity, freeMarker, jsp

时间:2016-12-06 20:25:08      阅读:178      评论:0      收藏:0      [点我收藏+]

标签: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

标签:sha   ref   cat   classpath   tty   init   div   map   freemark   

原文地址:http://www.cnblogs.com/ylz8401/p/6138758.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!