zoukankan      html  css  js  c++  java
  • Spring MVC多个视图解析器及优先级

    	<!-- Velocity视图解析器 默认视图 -->
    	<bean id="velocityViewResolver"
    		class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
    		<property name="contentType" value="text/html;charset=UTF-8" />
    		<property name="viewNames" value="*.html" />
    		<property name="suffix" value="" />
    		<property name="dateToolAttribute" value="date" />
    		<property name="numberToolAttribute" value="number" />
    		<property name="toolboxConfigLocation" value="/WEB-INF/velocity-toolbox.xml" />
    		<property name="requestContextAttribute" value="rc" />
    		<property name="order" value="0" />
    	</bean>
    
    
    	<bean id="velocityConfigurer"
    		class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
    		<property name="resourceLoaderPath" value="/WEB-INF/page/" />
    		<property name="velocityProperties">
    			<props>
    				<prop key="input.encoding">UTF-8</prop>
    				<prop key="output.encoding">UTF-8</prop>
    				<prop key="contentType">text/html;charset=UTF-8</prop>
    			</props>
    		</property>
    	</bean>
    
    
    	<!-- JSP视图解析器 -->
    	<bean id="viewResolverJsp"
    		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="prefix" value="/WEB-INF/page/" />
    		<property name="viewClass"
    			value="org.springframework.web.servlet.view.JstlView" />
    		<property name="viewNames" value="*.jsp" />
    		<property name="suffix" value="" />
    		<property name="order" value="1" />
    	</bean>
    
    
    	<!-- FreeMarker视图解析器 -->
    	<bean id="viewResolver"
    		class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
    		<property name="viewClass"
    			value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
    		<property name="contentType" value="text/html; charset=utf-8" />
    		<property name="cache" value="false" />
    		<property name="viewNames" value="*.ftl" />
    		<property name="suffix" value="" />
    		<property name="order" value="2" />
    	</bean>
    
    
    	<bean
    		class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
    		<property name="templateLoaderPath" value="/WEB-INF/page/" />
    
    <property name="freemarkerSettings">
    			<props>
    				<prop key="defaultEncoding">UTF-8</prop>
    			</props>
    		</property>
    	</bean>
    
    
                


    如果应用了多个视图解析器策略,那么就必须通过“order”属性来声明优先级,order值越低,则优先级越高

  • 相关阅读:
    idea 红线 并提示idea cant resolve symbol
    shell 脚本不能执行多条?何解
    怎么在linux下创建一个可运行脚本?
    java linux sdk1.8
    Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:co
    什么是结构化数据和非结构化数据?什么是数据清洗?
    Installation failed with message Failed to finalize session: INSTALL_FAILED_TEST_ONLY:installPackageLI.
    Tensorflow-目标检测之yolov3训练自己的模型
    Tensorflow-目标检测之yolov3训练自己的模型
    《C#高效编程》读书笔记11-理解短小方法的优势
  • 原文地址:https://www.cnblogs.com/zhousiwei/p/10625899.html
Copyright © 2011-2022 走看看