location.href方式跳转传值中文乱码解决

1、前端用encodeURI(encodeURI(plateName))两次转义;

var plateId = $(".plateContent").attr("plateId");//设置plateId
var plateName = $(".plateContent").html();//设置plateName
var dinersName = $("#dinersName").val();
var dinnerMobile = $("#dinnerMobile").val();
var userName = $("#userName").val();
var userMobile = $("#userMobile").val();
location.href="${ctx}/table/calendar.do?plateId="+plateId+""&plateName="+encodeURI(encodeURI(plateName))+
						"&dinersName="+encodeURI(encodeURI(dinersName))+
						"&dinnerMobile="+dinnerMobile+
						"&userName="+encodeURI(encodeURI(userName))+
						"&userMobile="+userMobile+
						"&advBookDays="+advBookDays;

2、Java后台用 URLDecoder.decode(name, "UTF-8")解码

String userName = URLDecoder.decode(wmTableorder.getUserName(), "UTF-8");

借鉴地址

你可能感兴趣的:(零碎知识整理,JavaScript)