- 博客(0)
- 资源 (2)
- 收藏
- 关注
springMVC3使用@ResponseBody向浏览器返回 json,注意区分jar包前缀
boolean jackson = true;
jackson ? org.codehaus.jackson : com.fasterxml.jackson ;
//jar前綴一定要對應配置代碼。
controller 配置:
@RequestMapping(value="/timeObject",produces = "application/json;charset=UTF-8" )
@ResponseBody
-----------------------------------------------------------------------------
<!-- @ResponseBody() spring-mvc 3 xml 配置-->
<!--处理 @ResponseBody 中文乱码问题 -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<!-- Support JSON -->
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
</list>
</property>
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver">
<property name="messageConverters">
<list>
<!-- Support JSON -->
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
</list>
</property>
</bean>
2018-09-14
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人