2
我想打电话从JSP(I帧)我的Spring MVC控制器和获取浏览器通过客户端发送的请求是语法不正确
400 Bad Request,The request sent by the client was syntactically incorrect()
这里下面的错误是我的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
});
});
这是我的控制器代码
@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);
}
}
同时击中提交按钮我得到的服务器上没有错误,但同时观察浏览器控制台输出它显示我下面的错误
"NetworkError: 400 Bad Request - https://localhost:9002/myApp/springSecurity/login.json"
这是Mozilla的响应头错误信息
the request sent by the client was syntactically incorrect().
我不知道什么导致了这种行为。 此外,我正在使用Spring安全来处理身份验证和授权。
编辑
我调试越来越发现,表单值没有被提交到我的控制器,当我在我的控制器TEY检查的j_username
和j_password
值来了空。
我甚至试过request.getParameter("param name");
但仍相同值来作为空
记住你也可以赞成答案。 ;-) – Stealth
你能否提供完整的请求,如Firebug所示(请求+数据)? –
@Stealth:同意并完成。感谢您的快速回答 –