1.千万不能吧@requestBody 后面的类,放在controller里面作为内部类。否则会有http415错误。
2 util:list的配置
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xmlns:mvc="http://www.springframework.org/schema/mvc"
[color=red]xmlns:util="http://www.springframework.org/schema/util"[/color]
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
[color=red]http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd[/color]">
3: MappingJacksonHttpMessageConverter的配置
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
[color=red]<util:list id="beanList"> [/color]
<ref bean="mappingJacksonHttpMessageConverter" />
[color=red] </util:list> [/color]
</property>
</bean>
<bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
4.ContentNegotiatingViewResolver的配置(这个由可能不需要)
<property name="mediaTypes">
<map>
[color=red]<entry key="json" value="application/json" /> [/color]
<entry key="html" value="text/html"/>
</map>
</property>
5.用json.min.js里面的postjson来发出ajax请求
6.需要json-core和json-mapper两个包
2 util:list的配置
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xmlns:mvc="http://www.springframework.org/schema/mvc"
[color=red]xmlns:util="http://www.springframework.org/schema/util"[/color]
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
[color=red]http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd[/color]">
3: MappingJacksonHttpMessageConverter的配置
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
[color=red]<util:list id="beanList"> [/color]
<ref bean="mappingJacksonHttpMessageConverter" />
[color=red] </util:list> [/color]
</property>
</bean>
<bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
4.ContentNegotiatingViewResolver的配置(这个由可能不需要)
<property name="mediaTypes">
<map>
[color=red]<entry key="json" value="application/json" /> [/color]
<entry key="html" value="text/html"/>
</map>
</property>
5.用json.min.js里面的postjson来发出ajax请求
6.需要json-core和json-mapper两个包