Java SpringMVC使用jackson解析对象?
我的豆子课Java SpringMVC使用jackson解析对象?,java,spring,jquery,spring-mvc,jackson,Java,Spring,Jquery,Spring Mvc,Jackson,我的豆子课 import java.util.LinkedList; public class Information { private LinkedList<String> information ; public LinkedList<String> getInformation() { return information; } public void setInformation(LinkedList<
import java.util.LinkedList;
public class Information {
private LinkedList<String> information ;
public LinkedList<String> getInformation() {
return information;
}
public void setInformation(LinkedList<String> information) {
this.information = information;
System.out.println("List is : "+information);
}
}
我的jquery将是
function registerDn(){
$.ajax({
type: "POST",
url: contexPath + "/registerDn.html",
data: "dn=" + dn + "&acd=" + acd,
success: function(response){
var userInfo = "<ol>";
for( i =0 ; i < response.information.length ; i++){
userInfo += "<br><li><b>Name</b> : " + response.information[i] ;
}
userInfo += "</ol>";
//Used to display the list
$('#getlist').html(dn + " is : " + userInfo);
},
error: function(e){
alert('Error: ' + e);
},
});
}
函数寄存器dn(){
$.ajax({
类型:“POST”,
url:contexPath+“/registerDn.html”,
数据:“dn=“+dn+”&acd=“+acd,
成功:功能(响应){
var userInfo=“”;
对于(i=0;i名称:”+response.information[i];
}
用户信息+=“”;
//用于显示列表
$('#getlist').html(dn+”是:“+userInfo”);
},
错误:函数(e){
警报('错误:'+e);
},
});
}
我在jquery-ajax中获得了成功,但不知道如何解析它并在视图中显示它
或者,当我单击按钮时,如何使用jqueryajax在bean类中获取列表
非常感谢您的回答。示例代码中没有任何内容表明响应应该是/应该是JSON对象
@RequestMapping
注释的products
属性,并将值设置为application/json
不过,您应该清楚地看到FireBug的情况。您已经完成了查看代码,只需更改$('#getlist').html(dn+”是:“+response.userInfo”);到$('#getlist').html(dn+”是:“+userInfo”)@Krisl显示
信息。长度为空或不是浏览器中的对象
错误?响应的内容是什么{}
?@wrm无法理解您在问什么?在ajax回调中:实际返回的是什么(即响应的内容
)?(因为它似乎不包含信息(或其空值))
function registerDn(){
$.ajax({
type: "POST",
url: contexPath + "/registerDn.html",
data: "dn=" + dn + "&acd=" + acd,
success: function(response){
var userInfo = "<ol>";
for( i =0 ; i < response.information.length ; i++){
userInfo += "<br><li><b>Name</b> : " + response.information[i] ;
}
userInfo += "</ol>";
//Used to display the list
$('#getlist').html(dn + " is : " + userInfo);
},
error: function(e){
alert('Error: ' + e);
},
});
}