<!--  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设置到最高,这是个坑,或者自己写解析器进行解析。