我在我的web应用程序中使用spring 3.0。我的应用程序中最近出现了一个问题。我在我的spring-servlet.xml文件中使用了<mvc:annotation-drive/>
标记,但由于要求,我必须删除它并放置XML配置。Spring MVC生成带引号的字段名称json输出
但现在我的问题是它生成带引号字段名称的json输出,如果我返回Boolean.TRUE
我在输出中得到了"true"
。我只想真正没有引号。
这里是我的XML配置
<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />
<bean id="pathMatcher" class="net.hrms.web.filters.CaseInsensitivePathMatcher" />
<bean name="handlerAdapter" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="webBindingInitializer">
<bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="conversionService" ref="conversionService"></property>
</bean>
</property>
<property name="messageConverters">
<list>
<ref bean="byteArrayConverter"/>
<ref bean="jaxbConverter"/>
<ref bean="jsonHttpMessageConverter"/>
<bean class="org.springframework.http.converter.StringHttpMessageConverter"></bean>
<bean class="org.springframework.http.converter.ResourceHttpMessageConverter"></bean>
<bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"></bean>
<bean class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter"></bean>
</list>
</property>
</bean>
<bean name="byteArrayConverter" class="org.springframework.http.converter.ByteArrayHttpMessageConverter"></bean>
<bean name="jaxbConverter" class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter"></bean>
<bean name="handlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
<property name="pathMatcher" ref="pathMatcher"></property>
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean id="jsonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="prefixJson" value="false"/>
<property name="supportedMediaTypes" value="application/json"/>
</bean>
任何帮助将是非常可观的。
能否请您确认这是默认的行为, - 你是不是从移开之前得到的报价'< mvc:annotation-driven />',在配置中似乎没有什么特别的地方可以做到这一点 –
我很确定当我使用' '我没有被引用的字段。但是现在我得到了引用的字段。我所有的jquery远程验证都会因此而失败, –