Spring MVC的@ResponseBody回来JSON串
时间:2014-01-23 19:14:41
收藏:0
阅读:484
1 406错误
<mvc:annotation-driven />不用动,请求的时候URL的文件扩展名应为json
@ResponseBody会根据扩展名,或者Header,或者Parameter来判断要返回的具体格式
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" /> <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"> <property name="favorPathExtension" value="true" /> <property name="favorParameter" value="false" /> <property name="ignoreAcceptHeader" value="true" /> <property name="mediaTypes"> <props> <prop key="json">application/json</prop> </props> </property> </bean>
2 failed to lazily initialize a collection of role
加入OpenSessionInViewFilter过滤器
原文:http://www.cnblogs.com/cuizhf/p/3530873.html
评论(0)