话不多说 上代码
这是前段js的代码 传的两个参数 cLassid 和 userid
$.ajax({
type:"post",
url:"../classsetting/addCounselor.do",
data:{"cLassid": cLassid, "userid": userid},
dataType:"json",
// contentType:"application/json;charset=UTF-8",
async:false,
success:function(data){
......
},error:function(jqXHR, textStatus, errorThrown){
.......
}
});
后台代码 如下
@RequestMapping(value = "addCounselor.do" )
public @ResponseBody int insertCounselor(HttpServletRequest request) {
String classid = request.getParameter("cLassid");//编辑编号
String counselor = request.getParameter("userid");//辅导员的 userID
//拿不到 ajax的 参数!!!! 原因在下面
int i = sysClassService.updateClassCounselor(counselor,classid);
return i;
}
结论! 为何会拿不带呢 ? 原因在于我的 Ajax
contentType:"application/json;charset=UTF-8" //这行代码要删掉
未更新完 待续。。。