0
我是Ajax新手。我试图打电话给我控制器的方法,但是从AJAX调用不调用URL我正在给..我在这里的控制方法,在我的JSP文件AJAX调用..Ajax不调用控制器方法
@RequestMapping(value = "/getdata", method = RequestMethod.POST)
public @ResponseBody String add(@RequestParam(value="userDetailObject", required=true) User_Details u,Model model) {
System.out.println("In the controller method..");
String result=null;
result="From controller :"+u.getEmail();
System.out.println("at controller .."+result);
return result;
}
和我的Ajax是
//script type="text/javascript" src="../jquery-1.4.4.js"
var jq = jQuery.noConflict();
function getData() {
alert("hello");
// get the form values
var email = $('#email').val();
// var education = $('#education').val();
$.ajax({
type : 'POST',
dataType: 'json',
url : "/SpringDemoSts/getdata",
data : 'email=' + email,
success : function(response) {
// we have the response
//$('#info').html(response);
$('#email').val(response);
//$('#education').val('');
},
error : function(e) {
alert('Error: ' + e);
}
});
}
/script
我在这里做错了什么是错的?
OK饶人,我只是用简单的串...但仍然无法在我的方法调用.... – Bhushan 2013-03-01 12:57:46
我也改变了我的网址为\t \t URL:“/的GetData”, – Bhushan 2013-03-01 12:58:10
我不如果多数民众赞成他纠正请求映射,您也可以在类级别定义映射。你的数据没有正确映射到paraemter我想,你试图从电子邮件只创建user_object。这赢得了胜利。 – NimChimpsky 2013-03-01 13:03:05