无法使用ajax调用spring控制器

Sre*_*nth 2 java ajax jquery spring jsp

我试图使用ajax调用弹簧控制器,但无法进入控制器.我收到错误405请求方法'POST'不支持错误.我在这里保留我的代码,请给出建议来过来

这是我从jsp页面调用控制器的ajax代码,这里我得到的是anchor属性值.

basic.jsp

function organizationData(anchor) {
    var value = anchor.getAttribute('value');  
    $.ajax({  
        url : "manageOrganization",   
        method : "GET",   
        dataType: "json",
        contentType: 'application/json',
        data: {organizationId : value },    
        success : function(response) {  
            alert(response);   
         },  
         error : function(e) {  
          alert('Error: ' + e);   
         }  
    });
}
Run Code Online (Sandbox Code Playgroud)

调节器

@RequestMapping(value="/manageOrganization", method = RequestMethod.GET)
public String organizationData(@RequestParam String organizationId) {
 return organizationId+"   associated";
}
Run Code Online (Sandbox Code Playgroud)

在这里我应该将字符串作为ajax响应获取到jsp,但我收到错误消息.任何身体都可以帮助我.

关心Sree

tar*_*hah 5

对于json响应,您需要向@ResponseBody控制器方法添加注释.