写表的时候要进行对中文的转化
<%!
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("iso-8859-1");
String temp=new String(temp_t);
return temp;
} catch(Exception e)
{
}
return "null";
}
%>
String xx=...;
xx=getStr(xx);
<%!
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("iso-8859-1");
String temp=new String(temp_t);
return temp;
} catch(Exception e)
{
}
return "null";
}
%>
String xx=...;
xx=getStr(xx);
解决方案 »
- 子类可以同时继承接口和抽象类?
- RequestDispatcher.forward() 方法和HttpServletResponse.sendRedirect()方法的区别
- JSP网页需要刷新一次才能显示
- poi3.0 里的cell.setCellValue(String)方法是不是不能使用了呀
- 急!《jsp:usebean》的问题
- 大伙说说。这是什么问题。。。
- 有一个wsdl的地址,怎么查看?
- 这个问题有点难,About MySQL.
- 大家能不能少说点UP之类的话,来点实际
- 我到底错在哪(数据库问题,高手请进!)
- 我编译JSP文件时提示,不知道它在说什么!请各位点点
- 数据库的问题(连接出错)请帮忙
2.JSP页面中加入一条语句:
<%@ page contentType="text/html;charset=gb2312" %>
3.编译servlet使用:
javac -encoding iso8859-1 myservlet.java
在jsp的zone配置文件中,修改编译参数为:
compiler = builtin-javac -encoding ISO8859-1
4.CLASSPATH中加入i18n.jar的路径
5.源程序中加入代码变换函数:
<%!
public 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";
}
%>
6.如果是直接赋值的中文字串,用<%@ page contentType="text/html;charset=gb2312" %>
就足够了。
7.如果使用request传过来的中文字串,用getStr(String)方法转换后使用。