以下javascript代码与出现的facebook登录窗口一起使用,并允许用户登录.捕获响应值,我知道它可以在设置中出现警报,但我无法将值传递回控制器方法.
@RequestMapping(value ="/getAccessToken" , method = RequestMethod.POST) public @ResponseBody String getAccessToken(@RequestBody String token){ System.out.println(token); return token; }
Javascript方法调用:
function doLogin() { FB.login(function(response) { alert(response); console.log(response); if (response.authResponse) { alert(response.authResponse.userID); alert(response.authResponse.accessToken); var Token = response.authResponse.accessToken; alert(Token); $.ajax({ type: "POST", url: "/HelloController/getAccessToken", data: Token, success: function (result) { alert("Token"); }, error: function (result) { alert("oops"); } }); document.getElementById('loginBtn').style. display = 'none'; getUserData(); }}, {perms:'manage_pages', scope: 'email,public_profile', return_scopes: true}); };
我得到的错误如下:
WARN 25660 --- [nio-8080-exec-9] o.s.web.servlet.PageNotFound : Request method 'POST' not supported
感谢回应.