前台页面:
function getCityTList() {
//更改用户权限
var provinceId=$("#selectedProvinceId").find("option:selected").val();
if (provinceId !=null) {
$.post("<%=basePath%>pstnTerminal/setPstnUserPriv.do", {
"provinceId" : provinceId
}, function() {
alert(ok);
});
}
}
后台代码:
@RequestMapping(value="/setPstnUserPriv", method = RequestMethod.POST)
@ResponseBody
public void setPstnUserPriv(HttpServletRequest request,HttpServletResponse response,String provinceId){
User user=(User) request.getSession().getAttribute("userInfo");
if(!provinceId.equals("")&&!provinceId.equals("-1")){//如果选择了省就将权限降级例外情况都是全国
user.setJG_CODE(provinceId);;//将其机构代码变为省的编码
Orga orga = orgaService.getOrgaByCode(user.getJG_CODE());
if(null != orga){
user.setOrga(orga);
}
//改掉原来的
request.getSession().setAttribute("userInfo", user);
}
}
浏览器报错:
jquery-1.8.3.js:8434 POST http://localhost:8080/HS/%3C%=basePath%%3Epst nTerminal/setPstnUserPriv.do 400 (Bad Request) jquery-1.8.3.js:8434
$.post(" < %=basePath% > pstnTerminal/setPstnUserPriv.do",
http://localhost:8080/HS/%3C%=basePath%%3Epst nTerminal/setPstnUserPriv.do
你的路径错误 从下面可以看到已经有了服务器地址 所以上面的url去掉 < %=basePath % >
即:$.post("pstnTerminal/setPstnUserPriv.do",
如果不行 :$.post("/pstnTerminal/setPstnUserPriv.do",