关于地址传值时的一个问题 地址中传值,必须要将它的编码转化发送时:name=URLEncoder.encode(name);接收时:name=new String(name.getBytes("ISO8859-1"),"GB2312"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果是javascript传给jsp呢如:var name="人民"; window.open("sales.jsp?name="+name,"","");在jsp中怎么做 显示时文件头上加:<%@ page contentType="text/html;charset=gb2312" %>request.getParameter("name"); 可以用window.open("sales.jsp?name=<%=name%>","",""); <%@ page contentType="text/html;charset=gb2312" %>改成:<%@ page contentType="text/html;charset=ISO8859_1" %> //试试下面的每个方法,转换得到的参数!public static String iso8859togbk(String strvalue) { try{ if(strvalue==null) return null; else { strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK"); return strvalue; } }catch(Exception e){ return null; } } public static String iso8859togb2312(String strvalue) { try{ if(strvalue==null) return null; else { strvalue = new String(strvalue.getBytes("ISO8859_1"), "gb2312"); return strvalue; } }catch(Exception e){ return null; } } public static String gb2312to8859(String strvalue) { try{ if(strvalue==null) return null; else { strvalue = new String(strvalue.getBytes("gb2312"), "ISO8859_1"); return strvalue; } }catch(Exception e){ return null; } } public static String gbkto8859(String strvalue) { try{ if(strvalue==null) return null; else { strvalue = new String(strvalue.getBytes("gbk"), "ISO8859_1"); return strvalue; } }catch(Exception e){ return null; } } 在sales.jsp得到这个name值的时候做一个转换;name=codeformat(name);codeformat函数如下: public String codeformat(String ss) { //处理中文问题 try{ String temp_p=ss; byte[] temp_t=temp_p.getBytes("ISO8859-1"); ss=new String(temp_t); }catch(Exception e){ System.err.println("toChinese exception:"+e.getMessage()); }return ss; } 紧急求助:使用母版页的页面参数传递的方法 弱弱的问一个js的问题 为什么我的分隔符不能使用||| 如何赚钱 tomcat奇怪的问题100分求解答 A页是登录页面,进入B页,然后从B页跳转到C页,此时在C页按 "后退" 按钮,要求不能进入B页。必须重新登录 求smartupload组件(在线等待,收到后马上结贴) 遇到个并发的问题。急求啊。 有关SQL检索的问题啊?? 如何绕过Servlet引擎的权限管理,将信息写入配置文件 请问tomcat下怎么运行一个servlet? 有关时间的显示????
如:
var name="人民";
window.open("sales.jsp?name="+name,"","");
在jsp中怎么做
<%@ page contentType="text/html;charset=gb2312" %>
request.getParameter("name");
改成:
<%@ page contentType="text/html;charset=ISO8859_1" %>
public static String iso8859togbk(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK");
return strvalue;
}
}catch(Exception e){
return null;
}
} public static String iso8859togb2312(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("ISO8859_1"), "gb2312");
return strvalue;
}
}catch(Exception e){
return null;
}
} public static String gb2312to8859(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("gb2312"), "ISO8859_1");
return strvalue;
}
}catch(Exception e){
return null;
}
}
public static String gbkto8859(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("gbk"), "ISO8859_1");
return strvalue;
}
}catch(Exception e){
return null;
}
}
name=codeformat(name);
codeformat函数如下:
public String codeformat(String ss) {
//处理中文问题
try{
String temp_p=ss;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
ss=new String(temp_t);
}catch(Exception e){
System.err.println("toChinese exception:"+e.getMessage());
}
return ss;
}