springmvc view

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
            http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
    <!-- Static resource mapping -->
	<mvc:resources mapping="/static/**" location="/static/" cache-period="172800"/>
	<!-- Register mapping, class information, etc... -->
	<mvc:annotation-driven />
	<!-- enable aop -->
	<aop:aspectj-autoproxy />
	<!-- scan annotation -->
	<context:component-scan base-package="com.easilycms.blog" />

	<!-- Configure the interceptor-->
	<mvc:interceptors>
		<bean class="org.springframework.web.servlet.mvc.WebContentInterceptor">
			<property name="cacheSeconds" value="0" />
			<property name="useExpiresHeader" value="true" />
			<property name="useCacheControlHeader" value="true" />
			<property name="useCacheControlNoStore" value="true" />
			<property name="alwaysUseFullPath" value="true" />
		</bean>
	</mvc:interceptors>

	<!-- Multi-view parsing.json .xml -->
	<bean
		class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
		<property name="order" value="1" />
		<!-- The default for enabling /userinfo/123?format=json support is true -->
		<property name="favorParameter" value="false" />
		<!-- Default is true for disabling /userinfo/123.json support -->
		<property name="favorPathExtension" value="true" />
		<!-- Set to true to ignore support for Accept Header -->
		<property name="ignoreAcceptHeader" value="true" />
		<!-- The default display format when there is no extension, i.e.: "/user/1"-->
		<property name="defaultContentType" value="text/html" />
		<!-- extension to mimeType mapping, ie /user.json => application/json -->
		<property name="mediaTypes">
			<map>
				<entry key="json" value="application/json" />
				<entry key="xml" value="application/xml" />
			</map>
		</property>
		<property name="defaultViews">
	        <list>
	          <ref bean="jsonView" />
	          <ref bean="xmlViewer" />
	        </list>
	    </property>
	</bean>

	<!-- Set the configuration file path of freeMarker-->
	<bean id="freemarkerConfiguration"
		class="org.springframework.beans.factory.config.PropertiesFactoryBean">
		<property name="location" value="classpath:freemarker.properties" />
	</bean>

	<!-- Configure the template path of freeMarker-->
	<bean id="freemarkerConfig"
		class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
		<property name="freemarkerSettings" ref="freemarkerConfiguration" />
		<property name="templateLoaderPath">
			<value>/</value>
		</property>
		<property name="freemarkerVariables">
			<map>
				<entry key="xml_escape" value-ref="fmXmlEscape" />
			</map>
		</property>
	</bean>

	<bean id="freeMarkerView"
		class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
		<property name="order" value="2" />
		<property name="viewClass"
			value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
		<property name="prefix" value="WEB-INF/ftl/pages/" />
		<property name="suffix" value=".ftl" />
		<property name="contentType" value="text/html; charset=utf-8" />
	</bean>

	<bean name="jsonView"
		class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
		<property name="encoding">
			<value type="org.codehaus.jackson.JsonEncoding">UTF8</value>
		</property>
		<property name="extractValueFromSingleKeyModel" value="true"></property>
		<property name="contentType" value="application/json;charset=UTF-8" />
	</bean>
	
	<bean id="xmlViewer"
		class="org.springframework.web.servlet.view.xml.MarshallingView">
		<constructor-arg>
		  <bean class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
			<property name="classesToBeBound">
				<list>
				</list>
			</property>
		  </bean>
		</constructor-arg>
		<property name="contentType" value="application/xml;charset=UTF-8" />
	</bean>
	
	<!-- file upload -->
	<bean id="multipartResolver"
          class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!--1024**1024*5 is 5M-->
        <property name="maxUploadSize" value="5242880"/>
    </bean>

	<bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape" />
</beans>

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326755332&siteId=291194637