zoukankan      html  css  js  c++  java
  • springMVC 配置多个视图解析器

    <!-- html视图解析器 必须先配置freemarkerConfig,注意html是没有prefix前缀属性的-->  
       <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">    
           <property name="templateLoaderPath">    
               <value>/WEB-INF/view/html</value>    
           </property>    
       </bean>    
        <bean id="htmlviewResolver"    
           class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">    
           <property name="suffix" value=".html" />
            <!--order越小,优先级越高 --> 
           <property name="order" value="0"></property>   
           <property name="contentType" value="text/html;charset=UTF-8"></property>           
       </bean>  
         
       <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
           <!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 -->  
           <property name="prefix" value="/WEB-INF/view/jsp/" />  
           <property name="suffix" value=".jsp" />  
           <property name="viewClass" value="org.springframework.web.servlet.view.InternalResourceView"/> <!-- 不能用jstl的那个 -->  
           <property name="contentType" value="text/html;charset=UTF-8"/>  
            <property name="order" value="0"></property>  
       </bean>  
    

     配置不同类型视图解析器的时候,InternalResourceViewResolver必须放在最后

    需要引入freemarker-2.3.15.jar,低版本有问题

  • 相关阅读:
    每日一题20201109(15. 三数之和)
    每日一题20201106(169. 多数元素)
    每日一题之20201103(941. 有效的山脉数组)
    每日一题之20201102(349. 两个数组的交集)
    【USACO4.4】追查坏牛奶
    【九省联考2018】一双木棋
    【NOI2013】向量内积
    【HNOI2013】游走
    【ZJOI2008】骑士
    【HEOI2014】大工程
  • 原文地址:https://www.cnblogs.com/xiaoQ0725/p/9052725.html
Copyright © 2011-2022 走看看