Ume*_*thi 2 jquery spring spring-mvc spring-security
我试图从JSP(I-Frame)调用我的Spring MVC控制器并在浏览器上收到以下错误
400 Bad Request,The request sent by the client was syntactically incorrect ()
Run Code Online (Sandbox Code Playgroud)
这是我的JQuery代码向服务器发送请求
jQuery("#login").live('click', function(e) {
e.preventDefault();
jQuery.ajax({
url: "https://localhost:9002/myApp/springSecurity/login.json",
xhrFields: {
withCredentials: true
},
type: "POST",
crossDomain:true,
data: jQuery("#loginForm").serialize(),
contentType: "json",
success: function(data, status) {
alert(data);
alert(status);
if (data.loggedIn) {
// location.href = getHost() + '${ctx}/users';
//login_pannel
} else {
loginFailed(data);
}
},
error: loginFailed
});
});
Run Code Online (Sandbox Code Playgroud)
这是我的控制器代码
@Controller
@RequestMapping("springSecurity/login.json")
public class SpringSecurityLoginController
{
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
public SpringSecurityLoginStatus login(@RequestParam("j_username") final String username,
@RequestParam("j_password") final String password, final HttpServletRequest request, final HttpServletResponse response)
{
LOG.info("Starting login process");
return springSecurityLoginService.login(username, password, request, response);
}
}
Run Code Online (Sandbox Code Playgroud)
在点击提交按钮时,我在服务器上没有出现任何错误,但在查看浏览器控制台输出时,它显示以下错误
"NetworkError: 400 Bad Request - https://localhost:9002/myApp/springSecurity/login.json"
Run Code Online (Sandbox Code Playgroud)
这是来自Mozilla Response标头的错误信息
the request sent by the client was syntactically incorrect ().
Run Code Online (Sandbox Code Playgroud)
我不确定是什么导致了这种行为.另外,我使用Spring安全性来处理身份验证和授权.
编辑
我调试了更多,并发现表单值没有提交给我的控制器当我检查j_username和j_password我的控制器中的值时,tey将变为空.
我甚至尝试过,request.getParameter("param name");但仍然有相同的值为null
| 归档时间: |
|
| 查看次数: |
8746 次 |
| 最近记录: |