kristain

博客园 首页 新随笔 联系 订阅 管理

一、js与jsp:

1、转码:js处理

<script type="text/javascript">

var ch = "中文";

function test(ch){

var title = ch != '' ? encodeURI(encodeURI(ch)) : '';

var path = "test.jsp?title="+title;

}

</script>

2、解码:jsp处理

<%

String title = request.getParameter("title");

    title = title != null && !title.equals("") ? java.net.URLDecoder.decode(title, "utf-8") : "";

%>

二、jsp与jsp:

1、转码:jsp处理

<%

String title = "中文";

title = title != null && !title.equals("") ? java.net.URLEncoder.encode(title, "utf-8") : "";

%>

2、解码:jsp处理

<%

String title = request.getParameter("title");

    title = title != null && !title.equals("") ? java.net.URLDecoder.decode(title, "utf-8") : "";

%>

ie6     在地址栏上传递中文,在程序获取期间会出现乱码.

ie8     则不会发生上述问题

posted on 2011-08-15 09:37  kristain  阅读(5761)  评论(0编辑  收藏  举报