spring.wf-mvc.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wf-web-springmvc Show documentation
Show all versions of wf-web-springmvc Show documentation
Java Web Frame: wf-web-springmvc
<?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:p="http://www.springframework.org/schema/p" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <!-- 把标记了@Controller注解的类转换为bean --> <context:component-scan base-package="org.webframe.web.springmvc.controller" /> <!-- 注入AnnotationHandlerMapping --> <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/> <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <!-- 解析json请求数据,将json转换为java对象--> <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" /> <!-- 解析xml请求数据,将xml转换为java对象--> <bean class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"> <constructor-arg> <bean class="org.springframework.oxm.xstream.XStreamMarshaller"> <property name="streamDriver"> <bean class="com.thoughtworks.xstream.io.xml.DomDriver" /> </property> <property name="autodetectAnnotations" value="true"/> <!--可以与xml互换的对象,需要使用XStream的注解,注解的使用方法请参XStream官网 <property name="annotatedClasses"> <list> <value>com.xxx.XxxxDTO</value> </list> </property> --> </bean> </constructor-arg> </bean> <bean class="org.springframework.http.converter.FormHttpMessageConverter" /> <bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter" /> <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" /> <bean class="org.springframework.http.converter.StringHttpMessageConverter" /> <bean class="org.springframework.http.converter.ResourceHttpMessageConverter" /> <!--可以增加其他数据类型,请参考spring的API--> </list> </property> </bean> <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <!-- 使用ModuleTemplateLoader加载后缀为ftl的文件--> <property name="postTemplateLoaders"> <list> <bean class="org.webframe.web.springmvc.view.freemarker.JarTemplateLoader"/> </list> </property> <property name="defaultEncoding" value="UTF-8" /> <property name="configLocation" value="classpath:freemarker.properties"/> <property name="freemarkerVariables"> <map> <entry key="xml_escape"> <bean class="freemarker.template.utility.XmlEscape"/> </entry> <entry key="html_escape"> <bean class="freemarker.template.utility.HtmlEscape" /> </entry> </map> </property> <!--可以增加其他freemarker的配置,详情请参阅FreeMarkerConfigurerAPI--> </bean> <bean id="contentNegotiatingViewResolver" class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="order" value="1"/> <property name="ignoreAcceptHeader" value="true" /> <property name="mediaTypes"> <map> <entry key="json" value="application/json" /> <entry key="xml" value="application/xml" /> <entry key="html" value="text/html" /> </map> </property> <property name="defaultViews"> <list> <!-- for application/json --> <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" /> <!-- for application/xml --> <bean class="org.springframework.web.servlet.view.xml.MarshallingView"> <constructor-arg> <bean class="org.springframework.oxm.xstream.XStreamMarshaller"> <property name="supportedClasses"> <list> <value>org.webframe.core.model.BaseEntity</value> </list> </property> </bean> </constructor-arg> </bean> </list> </property> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.webframe.web.springmvc.view.jsp.JspCheckView"/> <property name="contentType" value="text/html;charset=utf-8" /> <property name="order" value="2"/> <property name="prefix" value="/jsp" /> <property name="suffix" value=".jsp" /> </bean> <bean class="org.webframe.web.springmvc.view.freemarker.JarFreeMarkerViewResolver"> <property name="order" value="3"/> <property name="cache" value="true" /> <property name="prefix" value="" /> <property name="suffix" value=".ftl" /> <property name="contentType" value="text/html;charset=utf-8" /> <property name="exposeRequestAttributes" value="true"/> <property name="exposeSpringMacroHelpers" value="true" /> </bean> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" p:basename="i18n/messages" /> </beans>