`

spring4-json.xml

阅读更多
<?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:aop="http://www.springframework.org/schema/aop" xmlns:cache="http://www.springframework.org/schema/cache" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jms="http://www.springframework.org/schema/jms" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:p="http://www.springframework.org/schema/p" xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd   
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd   
        http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd   
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd   
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd   
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd   
        http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.1.xsd   
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.1.xsd   
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd   
        http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd   
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd   
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd   
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd"
>
<context:component-scan base-package="com.kge" />
<cache:annotation-driven cache-manager="cacheManager" />
<bean id="cacheManagerFactory" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:shared="true">
<property name="configLocation" value="classpath:ehcache-setting.xml" />
</bean>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="cacheManagerFactory" />
</bean>
<!-- -->
<bean id="handlerAdapter" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="order" value="-1" />
<property name="messageConverters">
<list>
<!-- <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" /> -->
<ref bean="mappingJacksonHttpMessageConverter" />
</list>
</property>
<property name="webBindingInitializer">
<bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="conversionService">
<!-- 针对普通请求(非application/json) 前台的日期字符串与后台的Java Date对象转化, 此情况,应使用spring mvc本身的内置日期处理 -->
<!-- 可以在VO属性上加注解:@DateTimeFormat 需要类库joda-time -->
<bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
</bean>
</property>
</bean>
</property>
</bean>
<!-- json请求(application/json)返回值Date转String,全局配置 -->
<bean name="jacksonObjectMapper" class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean">
<property name="featuresToDisable">
<array>
<util:constant static-field="com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS" />
</array>
</property>
<!-- 如果想自定义,可以在VO属性上加注解:@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Consts.DATE_PATTERN.DATE_PATTERN_OBLIQUE,timezone = "GMT+8") -->
<property name="simpleDateFormat">
<value>yyyy-MM-dd HH:mm:ss</value>
</property>
</bean>
<!--避免IE执行Ajax时,返回JSON出现下载文件 -->
<!-- 自定义 -->
<bean id="mappingJacksonHttpMessageConverter" class="com.kge.service.oauth.oltu.control.CustomJackson2HttpMessageConverter">
<property name="objectMapper" ref="jacksonObjectMapper" />
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
<mvc:annotation-driven />
<mvc:default-servlet-handler />
<!-- -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
分享到:
评论

相关推荐

    Struts2开发常用jar包

    包含struts2-core-2.5.10.1.jar,struts2-jfreechart-plugin-2.5.10.1.jar,struts2-json-plugin-2.5.10.1.jar,struts2-junit-plugin-2.5.10.1.jar,struts2-bean-validation-plugin-2.5.10.1.jar,struts2-cdi-...

    spring-boot-reference.pdf

    20.2.4. Disabling Restart 20.2.5. Using a Trigger File 20.2.6. Customizing the Restart Classloader 20.2.7. Known Limitations 20.3. LiveReload 20.4. Global Settings 20.5. Remote Applications 20.5.1. ...

    spring和hibernate__jar包,详细说明看jar包列表

    以下是jar包列表 activation-1.1.jar activiti-engine-5.10.jar activiti-spring-5.10.jar antlr-2.7.7.jar aopalliance-1.0.jar aopalliance.jar asm-3.1.jar aspectjrt.jar ...xml-apis-1.0.b2.jar

    cxf+spring webservice jar包

    antlr-2.7.7.jar aopalliance-1.0.jar asm-3.3.1.jar commons-beanutils-1.8.3.jar ...xml-resolver-1.2.jar xmlbeans-2.5.0.jar xmlschema-core-2.0.3.jar xmlsec-1.5.2.jar xmltooling-1.3.2-1.jar xsdlib-2010.1.jar

    logback-spring.xml

    logback-spring.xml

    spring-boot-cli-2.0.5.RELEASE-bin.zip

    在浏览器的数据传输格式上采用Json,非xml,同时提供RESTfulAPI;SpringMVC框架用于数据到达服务器后处理请求;到数据访问层主要有Hibernate、MyBatis、JPA等持久层框架;数据库常用MySQL;开发工具推荐IntelliJIDEA...

    struts2.1.6+spring2.0+hibernate3.2常用配置包

    最近温习ssh2整合编程,顺便浏览下struts2有什么更新的消息,下载了新...xml-apis.jar //3 注:以下包为数据源连接池 相关 用到那个添加相应的包 c3p0-0.9.1.2.jar //3 commons-pool.jar //3 commons-dbcp.jar //3

    c3p0-0.9.1.2等等

    antlr-2.7.6rc1.jar(下面的略.jar) asm.jar asm-2.2.3.jar asm-attrs.jar aspectjrt.jar aspectjweaver c3p0-0.9.1.2 cglib-2.1.3 cglib-2.1.3 ...xml-apis (我做毕业设计时,用到的。需要的话拿去用)

    Spring主流jar包大全

    batik-xml-1.7.jar cas-client-core-3.2.1.jar cglib-3.1.jar ckfinder-2.3.jar ckfinderplugin-fileeditor-2.3.jar ckfinderplugin-imageresize-2.3.jar classmate-1.1.0.jar commons-beanutils-1.9.1.jar commons-...

    axis2相关jar包~eclipse支持插件包

    axis2-json-1.5.4.jar axis2-kernel-1.5.4.jar axis2-metadata-1.5.4.jar axis2-mtompolicy-1.5.4.jar axis2-saaj-1.5.4.jar axis2-soapmonitor-servlet-1.5.4.jar axis2-spring-1.5.4.jar axis2-transport-...

    271个java需要用的jar包

    cxf-rt-bindings-xml-2.7.4.jar cxf-rt-core-2.7.4.jar cxf-rt-databinding-jaxb-2.7.4.jar cxf-rt-frontend-jaxws-2.7.4.jar cxf-rt-frontend-simple-2.7.4.jar cxf-rt-transports-http-2.7.4.jar cxf-rt-ws-addr-...

    AXIS2实现webservice jar包

    activation-1.1.jar antlr-2.7.7.jar apache-mime4j-core-0.7.2.jar axiom-api-1.2.20.jar axiom-dom-1.2.20.jar axiom-impl-1.2.20.jar ...xml-resolver-1.2.jar xmlbeans-2.5.0.jar xmlschema-core-2.2.1.jar

    SSHJ Jar包

    XML解析用的 dom4J.jar 一大堆依赖的commons : commons-codec-1.4.jar commons-logging-1.1.3.jar commons-fileupload-1.3.jar commons-io-2.0.1.jar ..... 不一一述说. 注:Spring,hibernate:个人不建议现在使用...

    SSH等jar包

    │ json-lib-2.2.3-jdk15.jar │ prototype-1.6.0.3.js │ ├─hibernate │ │ ojdbc6.jar │ │ ojdbc6dms.jar │ │ │ ├─ehcache │ │ ehcache-1.2.3.jar │ │ ehcache.xml │ │ │ └─hibernate_lib ...

    spring-redis.xml

    jdk 及 json hash相比较性能速度,得出结论 hash相对于jdk来说慢一些,而jdk相对于json来说又慢了一些,故 json性能速度较快

    web项目常用jar包及说明.zip

    4.dom4j-1.6.1.jar(对dom4j的封装,是解析xml文件的) 5.javassist-3.9.0.GA.jar(一个开源的分析、编辑和创建Java字节码的类库) 6.jta-1.1.jar(hibernate对事务的处理) 7.slf4j-api-1.6.4.jar(一个日志系统的...

    guice-spring-3.2.3.zip

    Tools.zip,有用的工具包,如http客户端、json解析器、xml解析器、裁剪和调整图像大小等

    springmvc和mybatis集成全部jar包(全)

    lib/ibatis-sqlmap-2.3.4.726.jar lib/jackson-all-1.9.9.jar lib/javax.inject.jar lib/javax.wsdl-1.6.1.jar lib/jettison-1.1.jar lib/json-lib-2.4-jdk15.jar lib/jstl-1.2.jar lib/jxl.jar lib/oro-...

    axis2相关的jar包

    axiom-api-1.2.10.jar axiom-dom-1.2.10.jar axiom-impl-1.2.10.jar axis2-adb-1.5.4.jar axis2-adb-codegen-1.5.4.jar axis2-codegen-1.5.4.jar axis2-corba-1.5.4.jar axis2-fastinfoset-1.5.4...XmlSchema-1.4.3.jar

    Ajax-spring-mvc-ex.zip

    Ajax-spring-mvc-ex.zip,SpringMVC___:__,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。它用于创建动态网页,其中网页的小部分在不重新加载网页的情况下更改。

Global site tag (gtag.js) - Google Analytics