String kk=new String(request.getParameter("image").getBytes("ISO-8859-1"),"gb2312");
解决方案 »
- 编写树形菜单
- JSP的四种会话跟踪技术与Servlet的生命周期
- 绝望求助中,哪位兄弟做过页面切入flash音频播放器
- 面试官问了我一个sql查询时左连接与右连接的问题
- 怎么将双引号存入数据库?
- 如何实现在线视频录制(包括声音)?像网友(www.wangyou.com)网站那样的效果,浏览器访问页面,在页面中实现在线视频录制的效果。
- 怎么向applet中传递参数??
- 我想把文本文件中的内容(是一些html代码)存入数据库中该怎么办??
- 前几天有同学去面试,题及javabean,同学没答上来
- 请问MYSQL 和SQL SERVER的驱程放在哪个目录啊
- JAVA中是否有加密函数
- 请问,如何在Web页面中调用本地ActiveX控件的方法和属性?
跟你的head提交上去的没有关系,到你的环境中会重新编码
try{
if(strValue==null)
return null;
else
{
strValue = new String(strValue.getBytes("ISO8859_1"), "GBK");
return strValue;
}
}
catch(Exception e){
e.printStackTrace();
return null;
} }你把这个方法封装到你的BEAN中,就可以直接调用了
你也可以写一个函数,再调用它就行的!!
<%!
private String strrequest(String input){
if(input!=null){
try { char ch=' ';
StringBuffer buf=new StringBuffer(input.length()+6);
if(input==null || input.length()==0)return input;
for(int i=0 ;i<input.length(); i++){
ch=input.charAt(i);
if(ch==13) buf.append("");
if(ch=='<')buf.append("<");
else if(ch=='>')buf.append(">");
else if(ch=='\'')buf.append("´");
else if(ch=='\"')buf.append(""");
else if(ch==' ')buf.append(" ");
else
buf.append(ch);
}
input=buf.toString(); byte[] b_inputtemp=input.getBytes("8859_1");
String temp=new String(b_inputtemp,"gb2312");
return temp;
}
catch(Exception e){
return input;
}
}
else
return "";
}
%>
然后你就调用它就行的。
String yy=strrequest(request.getParameter("image"));这样就行了,你自己试试看。