我的豆类,
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);
}
}
我的控制器,
@RequestMapping(value="/registerDn.html",method=RequestMethod.POST)
public @ResponseBody Information registerDn( @RequestParam(value = "dn", required = false) String dn,
@RequestParam(value = "acd", required = false) String acd ){
System.out.println("DN is : "+dn+ " acd : "+acd);
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
UserOperation oper = (UserOperation)ctx.getBean("operation");
oper.registerDn(dn);
Information info = (Information) ctx.getBean("info");
return info;
}
我的 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);
},
});
}
我在 jquery-ajax 中获得了成功。但不知道如何解析它并在视图中显示它。
或单击按钮时如何使用 jquery-ajax 获取 bean 类中的列表。
好的答案绝对值得赞赏。