开发者

JQuery GET request not able to submit JSON data for spring controller

I am using Jquery 1.4.4 and Spring 3.0. This is really strange. When I submit AJAX request as GET type the spring controller is not getting invoked. However, for same request when I use POST method the controller gets invoked successfully. There is no other change other than using POST versus GET method. Can someone please help - Am I missing something? This is my JS and controller code.

The URL submitted based on fiddler is: http://localhost:8680/fxiapi/auth/login?{%22user%22:%22dd%22,%22pass%22:%22ss%22,%22org%22:%22dd%22}

        $.ajax({
      开发者_如何学Go      url: '/fxiapi/auth/login',
            type: 'GET',
            data: JSON.stringify({"user":uname,"pass":pswd,"org":org}),
            dataType: "json",
            contentType: "application/json; charset=UTF-8",
            processData: false,
            beforeSend: function(x) {
                if (x && x.overrideMimeType) {
                    x.overrideMimeType("application/json;charset=UTF-8");
                }
            },
            success: function(data) {
                this.authToken = data.authToken;
            },
            error: function() {
                alert('you are not authenticated');
            }
        });

@RequestMapping(value = "/login", method = RequestMethod.GET)
public
@ResponseBody
LoginResponse login(@RequestBody LoginRequest loginData, HttpServletResponse response)  {
       return null;
    }
}


Please see HTTP GET with request body

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜