当前位置: 技术问答>java相关
还是中文问题:url(/test/a/救救我.html),其中,test.jsp接受request参数并打印,weblogic6.0上运行,却总是乱码!
来源: 互联网 发布时间:2015-04-10
本文导语: test.jsp内容如下: out.println(new String(request.getParameter("a").getBytes("UTF-8"))); | 为什么不用 java.net Class URLEncoder java.lang.Object | +--java.net.URLEncoder static String encode(String s) Translates a stri...
test.jsp内容如下:
out.println(new String(request.getParameter("a").getBytes("UTF-8")));
out.println(new String(request.getParameter("a").getBytes("UTF-8")));
|
为什么不用
java.net
Class URLEncoder
java.lang.Object
|
+--java.net.URLEncoder
static String encode(String s)
Translates a string into x-www-form-urlencoded format.
java.net
Class URLEncoder
java.lang.Object
|
+--java.net.URLEncoder
static String encode(String s)
Translates a string into x-www-form-urlencoded format.
|
String sss ="你";
String line = new String(sss.getBytes("ISO-8859-1"),"GBK");
or
String line = new String(sss.getBytes("gb2312"));
String line = new String(sss.getBytes("ISO-8859-1"),"GBK");
or
String line = new String(sss.getBytes("gb2312"));
|
String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{
}
return "null";
}
试一试
or
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{
}
return "null";
}
试一试
or