如果我們想在網(wǎng)址的查詢參數(shù)中利用中文,則在提交到的頁面必須對中文參數(shù)進(jìn)行處理
例如:
<script>
location.href="goto.jsp?type=分類";
</script>
在goto.jsp頁面要獲取type參數(shù),需要對此參數(shù)進(jìn)行處理:
String type=(String)request.getParameter("type");
type=type==null?"":type.trim();
type=new String(type.getBytes("ISO-8859-1"),"GBK");
System.out.println("Type:"+type);//這樣才能正確輸出:Type:分類
例如:
<script>
location.href="goto.jsp?type=分類";
</script>
在goto.jsp頁面要獲取type參數(shù),需要對此參數(shù)進(jìn)行處理:
String type=(String)request.getParameter("type");
type=type==null?"":type.trim();
type=new String(type.getBytes("ISO-8859-1"),"GBK");
System.out.println("Type:"+type);//這樣才能正確輸出:Type:分類