- 浏览: 143927 次
文章分类
最新评论
-
niwai:
你好我用httpclient4.2 登录亚马逊怎么提示没有激活 ...
用httpclient开发的在线自动抢订火车票系统(铁老大不给力,哥给力)
spring MVC 中json格式数据发送与接收
在web程序开发中,前端和服务器数据的传输方式常用的有两种,一种是以表单的形式提交,此时可以利用jquery的serialize()方法将表单内容转为a=1&b=2&c=3&d=4&e=5这样的格式传输过去,接收端则可以用javabean直接接收。
还有一种方式是以json格式传输,接收时若直接用bean接收则接收不到,此时应该用@RequestBody方式,需要注意的是接收的需要是json串,而不是json对象,可以在发送前使用JSON.stringify函数进行处理。
例子如下
客户端:
<wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">var url=path+'testConverter.html';</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">$.ajax( {</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">url : url,</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">type : "POST",</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">dataType:"json",</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">contentType:'application/json;charset=UTF-8</span><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">',</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">data:JSON.stringify</span><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">({userId:'1',userName:'hello',password:'test',credits:'2',lastIp:'',lastVisit:'1986-05-27'}),</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">success : function(data) {</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">alert(data.userName);</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">},</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">error:function(e){</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">alert("err");</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">}</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">服务端:</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">@RequestMapping(value="/testConverter.html")</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">@ResponseBody</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">public User testConverter(@RequestBody User</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">user)</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">{</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">System.out.println(user.getUserName());</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">user.setUserName("testname");</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">return user;</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">}</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">上面例子中服务端返回的是个对象,@ResponseBody函数会自动将其转换为客户端要求的‘ dataType:"json",’格式。</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">最后需要注意的是在xxx-serverlet配置文件中应该写上,以便可以使用 @ResponseBody和@RequestBody</span> </wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
还有一种方式是以json格式传输,接收时若直接用bean接收则接收不到,此时应该用@RequestBody方式,需要注意的是接收的需要是json串,而不是json对象,可以在发送前使用JSON.stringify函数进行处理。
例子如下
客户端:
<wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">var url=path+'testConverter.html';</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">$.ajax( {</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">url : url,</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">type : "POST",</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">dataType:"json",</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">contentType:'application/json;charset=UTF-8</span><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">',</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">data:JSON.stringify</span><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">({userId:'1',userName:'hello',password:'test',credits:'2',lastIp:'',lastVisit:'1986-05-27'}),</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">success : function(data) {</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">alert(data.userName);</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">},</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">error:function(e){</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">alert("err");</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">}</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">服务端:</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">@RequestMapping(value="/testConverter.html")</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">@ResponseBody</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">public User testConverter(@RequestBody User</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">user)</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">{</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">System.out.println(user.getUserName());</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">user.setUserName("testname");</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">return user;</span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"></span><wbr style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">}</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">上面例子中服务端返回的是个对象,@ResponseBody函数会自动将其转换为客户端要求的‘ dataType:"json",’格式。</span><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><br style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)"><span style="color:rgb(68,68,68); font-family:simsun; font-size:14.399999618530273px; line-height:21.600000381469727px; background-color:rgb(243,248,251)">最后需要注意的是在xxx-serverlet配置文件中应该写上,以便可以使用 @ResponseBody和@RequestBody</span> </wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
相关推荐
本文通过代码实例介绍spring mvc 接收json数据的方法,具体详情如下所示: 接收JSON 使用 @RequestBody 注解前台只需要向 Controller 提交一段符合格式的 JSON,Spring 会自动将其拼装成 bean。 1)在上面的项目中...
最近使用ajax接收spring mvc传过来的json数据时总是出现parseerror的错误,下面通过本文给大家分享spring mvc 返回json数据到ajax报错parseerror问题的解决方法,需要的朋友参考下吧
附件是springmvc开发中与前台进行json数据的交互所需的jar包,参考文章:http://blog.csdn.net/eson_15/article/details/51742864
这是一个 spring mvc 框架 封装了 前台表单转成json数据 传递到后台 控制层 接收 json 数据,可以支持批量添加数据的功能。
主要为大家详细介绍了SpringMVC接收多个对象的4种方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
使用Spring MVC或Spring Boot中打印或记录日志一般使用AOP记录Request请求和Response响应参数,在不使用AOP的前提下,如果在Filter中打印日志,在打印或消费请求类型为Content-Type:application/json的请求时,会...
SpringMVC通过@ResponseBody传送json字符串到客户端,实现了REST接口远程调用功能,demo中使用的版本为spring3.2,代码中用到了注解,代码直接部署运行,已经通过测试(如在浏览器中输入...客户端返回后台传递的json格式数据)
下面小编就为大家分享一篇浅谈springMVC接收前端json数据的总结,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
ajax向springmvc传递json,
本篇文章主要介绍了springmvc 接收json对象的两种方式,具有一定的参考价值,有需要的可以了解一下。
在使用springMVC框架构建web应用,客户端常会请求字符串、整型、json等格式的数据,通常使用@ResponseBody注解使 controller回应相应的数据而不是去渲染某个页面。
而@RequestBody默认接收的enctype (MIME编码)是application/json,因此发送POST请求时需要设置请求报文头信息,否则Spring MVC在解析集合请求参数时不会自动的转换成JSON数据再解析成相应的集合。 以下列举接收List...
1.2 配置Spring IoC容器中的Bean 4 1.2.1 问题 4 1.2.2 解决方案 4 1.2.3 工作原理 4 1.3 调用构造程序创建Bean 14 1.3.1 问题 14 1.3.2 解决方案 14 1.3.3 工作原理 14 1.4 解决构造程序歧义 17 ...
1.2 配置Spring IoC容器中的Bean 4 1.2.1 问题 4 1.2.2 解决方案 4 1.2.3 工作原理 4 1.3 调用构造程序创建Bean 14 1.3.1 问题 14 1.3.2 解决方案 14 1.3.3 工作原理 14 1.4 解决构造程序歧义 17 ...
在Spring环境中使用YAML暴露属性 iii. 23.6.3. Multi-profile YAML文档 iv. 23.6.4. YAML缺点 vii. 23.7. 类型安全的配置属性 i. 23.7.1. 第三方配置 ii. 23.7.2. 松散的绑定(Relaxed binding) iii. 23.7.3. @...
Spring+SpringMVC+MyBatis+Thymeleaf+Vue+JS+Jquery+Axios+Json 服务器: Tomcat_9.0.60 数据库: MySQL_8.0.28 开发工具:IDEA_2021.3.3 页面:Bootstrap_3.3.0 ## 2️⃣已实现的功能 **:star: 账号登录** ...
Service接收商品的pojo,把商品数据写入到tb_item中,返回resultMap ##商品描述的保存 商品信息和商品描述是分开存储的。把商品信息描述保存到tb_item_desc表中。 ###规格参数 不同分类的规格参数不同,同一...