Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在发送返回值中的字符串时,ajax不起作用_Java_Ajax_Spring_Model View Controller_Return - Fatal编程技术网

Java 在发送返回值中的字符串时,ajax不起作用

Java 在发送返回值中的字符串时,ajax不起作用,java,ajax,spring,model-view-controller,return,Java,Ajax,Spring,Model View Controller,Return,我的ajax调用是 $.ajax({ type : "POST", headers : { 'X-CSRF-TOKEN' : $("meta[name='_csrf']").attr("content") }, url : url, contentType : "application/json", data : JSON.stringify(subdata), success : function(data) {

我的ajax调用是

$.ajax({
    type : "POST",
    headers : {
        'X-CSRF-TOKEN' : $("meta[name='_csrf']").attr("content")
    },
    url : url,
    contentType : "application/json",
    data : JSON.stringify(subdata),
    success : function(data) {
        alert("Added sussefull");
        alert(data);
        alert(data.message);
    },
    error : function() {
        alert("in error");
    }
});
我的控制器

@RequestMapping(value="/addcourse",method =RequestMethod.POST,produces = "application/json")
public @ResponseBody String addCourse(@RequestBody Subject subject) 
{       
    String message = subjectService.addSub(subject);
    return message;
}

若我发送字符串值,若我更改字符串使其无效,那个么Ajax调用将不起作用

不工作,如果我发送字符串值,如果我改变字符串,使其无效的工作,你能详细说明吗?分享您得到的错误您的
子数据在哪里?您是否收到了错误的警告?