开发者

In spring mvc, headers = "x-requested-with:XMLHttpRequest" in request mapping not working?

I have two methods, one is supposed to handle login request issued by JS, another takes care of login page.

 @RequestMapping(value = "/login", method = {RequestMethod.GET, R开发者_如何学JAVAequestMethod.HEAD},
    headers = "x-requested-with:XMLHttpRequest")
    public @ResponseBody String login() {...}


 @RequestMapping(value = "/login", method = {RequestMethod.GET, RequestMethod.HEAD})
    public String getLoginPage() {......}

However, all the login requests seems to go to the getLoginPage method whether it has "x-requested-with:XMLHttpRequest" header or not. I doubled checked http headers, it contains correct head. So it seems Spring just ignores the login method.

I've been struggling with this for a while, any advice would be greatly appreciated, thanks!


headers uses = as a delimiter:

@RequestMapping(value = "/login", method = {RequestMethod.GET, RequestMethod.HEAD},     
    headers = "x-requested-with=XMLHttpRequest") 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜