當前所使用的jsp服務器中,常用的有resin和tomcat兩種,resin對中文的支持比較好,但大部分初學者或者大部分人還是習慣於使用tomcat服務器,這其中就常常遇到中文解決的問題,寫了個函數來解決:
String CStr(String str)
{
String result = str;
if(result==null) result="";
try
{
result = new String(result.getBytes("ISO8859_1"),"GB2312");
}
catch(Exception e)
{ e.printStackTrace(); }
return result;
}
來處理tomcat運行的jsp文件傳送中文參數的問題。