为什么我在js 用url 向action传中文参数的时候 在action 用request.getParameter() 接受的时候 显示的是乱码?
我js 代码如下:
function goBut()
{
var sys =document.getElementById( "select1 ").value;
var tab =document.getElementById( "select2 ").value;
alert(sys);
alert(tab);
window.location.href= "fieldDefine.do?method=findAllFieldDefineByTable&sysname= "+sys+ "&tablename= "+encodeURIComponent(tab);
} 弹出来的都有值, 就是tab里面的值是中文 传过去就是乱码。 我用encodeURIComponent(),escape(), 和在action里面用java.net.URLEncoder.encode(tab, "utf-8 ");解码 都没用,请高手解决...
我js 代码如下:
function goBut()
{
var sys =document.getElementById( "select1 ").value;
var tab =document.getElementById( "select2 ").value;
alert(sys);
alert(tab);
window.location.href= "fieldDefine.do?method=findAllFieldDefineByTable&sysname= "+sys+ "&tablename= "+encodeURIComponent(tab);
} 弹出来的都有值, 就是tab里面的值是中文 传过去就是乱码。 我用encodeURIComponent(),escape(), 和在action里面用java.net.URLEncoder.encode(tab, "utf-8 ");解码 都没用,请高手解决...
submit=encodeURI(submit);
window.location.href=submit
用这个encodeURI可以解决,我也碰到过了。
不行就encodeURI然后在服务器端再解析回来。
action中用java.net.URLDecoder.decode( tablename, "UTF-8" )接收,就可以了