在SpringMVC应用程序中,没有使用jQueryAjax方法检索从控制器返回作为responsebody的对象?
该对象不会在ajax方法中返回,也不会引发异常。。 控制器方法中的代码: 我从这个方法返回一个EmployeeBean对象,作为在SpringMVC应用程序中,没有使用jQueryAjax方法检索从控制器返回作为responsebody的对象?,jquery,ajax,json,spring,model-view-controller,Jquery,Ajax,Json,Spring,Model View Controller,该对象不会在ajax方法中返回,也不会引发异常。。 控制器方法中的代码: 我从这个方法返回一个EmployeeBean对象,作为@Responsebody @RequestMapping(value="/anki") public @ResponseBody EmployeeBean hhh(@RequestParam("name")String name){ System.out.println("new method"); EmployeeBean e=new Employe
@Responsebody
@RequestMapping(value="/anki")
public @ResponseBody EmployeeBean hhh(@RequestParam("name")String name){
System.out.println("new method");
EmployeeBean e=new EmployeeBean();
e.setId("1001");
e.setName("ankita");
return e;
}
Bean类EmployeeBean
package com.controller;
public class EmployeeBean {
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
在ajax方法响应未成功发出的情况下,控制器中的URL正确匹配
javascript代码:
function abc(){
alert('here!!');
$.ajax({
url:'anki',
data:({name : "me"}),
success:function(data){
alert('here gain');
$('#time').html(data.name);
}
});
}
<input type="button" name="submit" title="submit" onclick="abc()"/>
<div id="time"></div>
函数abc(){
警惕('here!!');
$.ajax({
网址:"安基",,
数据:({name:“me”}),
成功:功能(数据){
警报(“此处增益”);
$('#time').html(data.name);
}
});
}
如果类路径中没有Jackson库,请添加它。添加jackson-core-asl-1.6.4和jackson-mapper-asl-1.6.4 jars如果您对该url进行非ajax调用,比如从浏览器发出get请求,您的类路径中是否有jackson库?