第一种情况:
我要将name传到后台,其中name是汉字
这样我可以在url后面加上
例如url="publicResult.do&name="+encodeURI(encodeURI(name))
然和在后台当中取的时候是这样的
name = org.directwebremoting.util.LocalUtil.decode(name);
别急,还缺少一个jar包,
dwr.jar
第二种情况:
通过js将a.jsp的title中文值传到b.jsp页面,因为js传递url是采用utf-8的编码格式
所以传递之前应该先编码
a.jsp中
js函数:
通过encodeURL对title进行编码!
b.jsp中
js函数:
通过 decodeURI对title进行编码!
这样传递的title如果是中文的话就不会乱码了!
我要将name传到后台,其中name是汉字
这样我可以在url后面加上
例如url="publicResult.do&name="+encodeURI(encodeURI(name))
然和在后台当中取的时候是这样的
name = org.directwebremoting.util.LocalUtil.decode(name);
别急,还缺少一个jar包,
dwr.jar
第二种情况:
通过js将a.jsp的title中文值传到b.jsp页面,因为js传递url是采用utf-8的编码格式
所以传递之前应该先编码
a.jsp中
js函数:
function submit()
{
var title=encodeURI(document.wordform.title.value);
location.href="a.jsp?title="+title;
}
通过encodeURL对title进行编码!
b.jsp中
js函数:
function showValue(){
var str=document.URL;
var title = decodeURI((str.substring(str.indexOf("=")+1)));
alert(title);
}
通过 decodeURI对title进行编码!
这样传递的title如果是中文的话就不会乱码了!