解决URL传递中文乱码问题:
一、URL中文字段的编码:
function test(taskId, name) {
var taskName = escape(encodeURIComponent(name));
var url = "${ctx}/act/task/form?taskId=" + taskId + "&name="+ name;
location = url
}
<a href="javascript:test('${task.id}','${task.name}');">XXXX</a>
二、a标签模拟form表单的post请求:
function post(url, params) {
var temp = document.createElement("form");
temp.action = url;
temp.method = "post";
temp.style.display = "none";
for (var x in params) {
var opt = document.createElement("textarea");
opt.name = x;
opt.value = params[x];
temp.appendChild(opt);
}
document.body.appendChild(temp);
temp.submit();
return temp;
}
<a href="javascript:;" onclick="javascript:post('${ctx}/tbbh/custbaseinfo/list',{custNm:'${custNm}'})">${custNm}</a>