request.getParameter("name")之后,把它转换一下,String strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK");
就可以了!!
就可以了!!
解决方案 »
- 几道面试题
- Spring Hibernate save无法插入到数据库中(上网搜过了,但是没有找到解决的办法)
- MongoDB存储字符串时的问题
- 学习SSH,问题多多,接踵而至,望各位大狭帮帮忙!
- 关于Spring 未形成规范的问题
- URLConnection的哪一个请求属性(RequestProperty)是用于指示Servlet容器按指定的编码来解码参数??
- 紧急求助!!!!连接数据库突然变慢!!!
- hibernate问题, jndi错误.
- SOAPException异常,请教给为高手!
- j2eesdk 的 问题?
- 做EntityBean,数据库用JDBC-ODBC连接可不可以啊?或者说可以用什么样子的数据库连接?
- weblogic7建不了连接池,怎么办?
1:在jsp页面加入:
<%@ page contentType="text/html; charset=gb2312" %>
2:在servlet里面:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=gb2312");//这是重要的3:上面的如果在不行就用如下的方法在数据入库前进行调用:
public static String UnicodeToChinese(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}public static String ChineseToUnicode(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("gb2312"),"ISO8859_1");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}4:)解决weblogic/webshpere中文问题:
在web.xml文件中需要配置中文环境。r如下:
<context-param>
<param-name>weblogic.httpd.inputCharset./*</param-name>
<param-value>GB2312</param-value>
</context-param>
在你的JAVABEAN 中调用方法给以转化。
方法自己写哦!