各位大神帮忙看一下。。。这是我的web.xml中的相关配置:<servlet-mapping>
<servlet-name>ttt</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>然后这是前台ajax:<script type="text/javascript">
function logIn() {
var user_json = {
"userName": "admin",
"password": "E10ADC3949BA59ABBE56E057F20F883E"
}
var jason_str = JSON.stringify(user_json);
alert(jason_str);
$.ajax({
url: "/checkUserLogin.do",
type: "post",
datatype: "json",
contentType: "application/json; charset=utf-8",
data: jason_str,
success: function (data) {
alert("success");
}
});
}
</script>下面是后台接受的代码:@RequestMapping(value = "/checkUserLogin.do")
public @ResponseBody User checkUserLogin(@RequestBody User user){
System.out.println(user);
if(user.getUserName()=="admin"){
user.setUserName("NameOK");
}else{
user.setUserName("FUCK");
}
if(user.getPassword()=="E10ADC3949BA59ABBE56E057F20F883E"){
user.setPassword("PasswordOK");
}else{
user.setPassword("FUCK");
}
return user;
}现在问题多半出在ajax的url路径上的问题,前台alert(jason_str);成功执行,但是到后台没能接受到ajax请求。。。试问一下各位大神,这个url写的有问题吗?
添加回答
举报
0/150
提交
取消