各位大神幫忙看一下。。。這是我的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;
}現(xiàn)在問題多半出在ajax的url路徑上的問題,前臺alert(jason_str);成功執(zhí)行,但是到后臺沒能接受到ajax請求。。。試問一下各位大神,這個url寫的有問題嗎?
關于ssm框架json+ajax前后臺數(shù)據(jù)交互的問題
一只會編程的狗子
2017-04-11 17:29:37