springmvc多视图解释配置详解

spring mvc多视图解释,配置详解

 

[xml][/xml]
  1. <?xml version=”1.0″ encoding=”UTF-8″?>
  2. <beans xmlns=”http://www.springframework.org/schema/beans”
  3.     xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
  4.     xmlns:p=”http://www.springframework.org/schema/p”
  5.     xmlns:context=”http://www.springframework.org/schema/context”
  6.     xsi:schemaLocation=”
  7.     http://www.springframework.org/schema/beans
  8.     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  9.     http://www.springframework.org/schema/context
  10.     http://www.springframework.org/schema/context/spring-context-3.0.xsd”>
  11.     <context:component-scan
  12.         base-package=”com.spring.action” />
  13.     <!–
  14.         org.springframework.web.servlet.view.ResourceBundleViewResolver
  15.         用于多个视图集成时,ResourceBundleViewResolver是通过解析资源文件来解析请求输出文件的。
  16.         <property name=”basename” value=”views”></property>,即表示在/WEB-INF/classes路径下有一个
  17.         views.properties文件,本例中views.properties的内容为
  18.         welcome.(class)=org.springframework.web.servlet.view.velocity.VelocityView
  19.         welcome.url=welcome.vm
  20.         freemarker.(class)=org.springframework.web.servlet.view.freemarker.FreeMarkerView
  21.         freemarker.url=freemarker.ftl
  22.     –>
  23.     <bean class=”org.springframework.web.servlet.view.ResourceBundleViewResolver”>
  24.         <property name=”basename” value=”views”></property>
  25.         <!–
  26.             <property name=”order” value=”0″></property>
  27.         –>
  28.     </bean>
  29.     <!– jsp视图解析器 –>
  30.     <bean id=”jspViewResolver” class=”org.springframework.web.servlet.view.InternalResourceViewResolver”>
  31.         <property name=”viewClass” value=”org.springframework.web.servlet.view.JstlView”/>
  32.         <property name=”prefix” value=”/”/>
  33.         <property name=”suffix” value=”.jsp”/>
  34.     </bean>
  35.     <!– velocity视图解析器 –>
  36.     <bean id=”velocityViewResolver” class=”org.springframework.web.servlet.view.velocity.VelocityViewResolver”>
  37.         <property name=”cache” value=”true”/>
  38.         <property name=”prefix” value=”/”/>
  39.         <property name=”suffix” value=”.vm”/>
  40.     </bean>
  41.     <!– velocity环境配置 –>
  42.     <bean id=”velocityConfig” class=”org.springframework.web.servlet.view.velocity.VelocityConfigurer”>
  43.         <!– velocity配置文件路径 –>
  44.         <property name=”configLocation” value=”/WEB-INF/velocity.properties”/>
  45.         <!– velocity模板路径 –>
  46.         <property name=”resourceLoaderPath” value=”/WEB-INF/velocity/”/>
  47.     </bean>
  48.     <!– FreeMarker环境配置 –>
  49.     <bean id=”freemarkerConfig” class=”org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer”>
  50.         <!– freemarker模板位置 –>
  51.         <property name=”templateLoaderPath” value=”/WEB-INF/freemarker/”/>
  52.     </bean>
  53.     <!– FreeMarker视图解析 –>
  54.     <bean id=”freeMarkerViewResolver” class=”org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver”>
  55.         <property name=”cache” value=”true”/>
  56.         <property name=”prefix” value=”/”/>
  57.         <property name=”suffix” value=”.ftl”/>
  58.     </bean>
  59. </beans>

标签