`
baishuo491
  • 浏览: 78317 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

springmvc + jason ajax

 
阅读更多
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"
       xmlns:util="http://www.springframework.org/schema/util"
       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
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util-2.0.xsd
">

3:     MappingJacksonHttpMessageConverter的配置

    <bean 
        class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> 
        <property name="messageConverters"> 
            <util:list id="beanList"> 
                <ref bean="mappingJacksonHttpMessageConverter" /> 
           </util:list> 
        </property> 
    </bean> 
     
    <bean id="mappingJacksonHttpMessageConverter" 
        class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />

4.ContentNegotiatingViewResolver的配置(这个由可能不需要)
<property name="mediaTypes">
<map>
    <entry key="json" value="application/json" />
<entry key="html" value="text/html"/>
</map>
</property>

5.用json.min.js里面的postjson来发出ajax请求
6.需要json-core和json-mapper两个包
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics