问题描述
- 关于springmvc集成jackson问题
-
将jackson配置进spring内,利用spring的自动转化json向页面输出json数据,现在的情况是@jsonignore这个注解不被spring识别,但是我利用jackson的转换json的代码却可以正确实现,现贴上配置,求救
ignoreDefaultModelOnRedirect="true" validator="validator"
conversion-service="conversionService">class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"
p:supportedMediaTypes="text/html;charset=UTF-8">/mvc:message-converters
/mvc:annotation-driven<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"> <property name="converters"> <set> <bean class="com.suning.cybertron.superion.common.util.DateTimeConvert" /> </set> </property> </bean> <bean id="webBindingInitializer" class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer"> <property name="conversionService" ref="conversionService" /> </bean> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> <property name="webBindingInitializer" ref="webBindingInitializer" /> </bean> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter" /> </list> </property> </bean> <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> 实体类中: @ManyToMany(mappedBy="users") @JsonIgnore private Set<AlarmInfo> alarmInfos;
解决方案
SpringMVC中使用jackson,注解@ResponseBody返回中文乱码问题
时间: 2024-11-08 19:11:35