导航

spring mvc json乱码

Posted on 2017-07-09 17:21  曙光城邦  阅读(144)  评论(0编辑  收藏  举报
    <mvc:annotation-driven>
    	<mvc:message-converters>
    		     <!-- 将StringHttpMessageConverter的默认编码设为UTF-8 -->
			<bean class="org.springframework.http.converter.StringHttpMessageConverter">
		    	<constructor-arg value="UTF-8" />
			</bean>
    	</mvc:message-converters>
    </mvc:annotation-driven>
    

 配置默认转换器的编码格式为UTF-8,源码里是ISO-8859-1

 

-------------------------------

<mvc:annotation-driven>标签开启了13个bean

包含了替换3.1之前的废弃bean

DefaultAnnotationHandlerMapping -> RequestMappingHandlerMapping

AnnotationMethodHandlerAdapter -> RequestMappingHandlerAdapter

AnnotationMethodHandlerExceptionResolver -> ExceptionHandlerExceptionResolver

---------------------------------------13个bean

mvcContentNegotiationManager,
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping,-----------启用了最新的RequestMappingHandlerMapping
mvcCorsConfigurations,
org.springframework.format.support.FormattingConversionServiceFactoryBean#0,
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter,---------启用了最新的RequestMappingHandlerAdapter
mvcUriComponentsContributor,
org.springframework.web.servlet.handler.MappedInterceptor#0,
org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,----------启用了最新的ExceptionHandlerExceptionResolver
org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,
org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,
org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,
org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,