解决办法:
第一:
在jsp页面加入:
<%@ page contentType="text/html; charset=gb2312" %>
或者在servlet里面
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=gb2312");
上面的如果在不行就用如下的方法在数据入库前进行调用:
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;
}
}
第一:
在jsp页面加入:
<%@ page contentType="text/html; charset=gb2312" %>
或者在servlet里面
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=gb2312");
上面的如果在不行就用如下的方法在数据入库前进行调用:
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;
}
}
解决方案 »
- 模拟实现 DOS 一些命令 比如dir ab*则 显示ab开头的文件 怎么做
- 一个小小的跳出循环问题,请教一下,在线等!!
- tomcat在Eclipse里面启动不显示启动时间:记得应该有Server start up in ……ms的
- override the method in superclass/interface
- 很奇怪的一道题,希望大家帮忙看看是怎么回事
- java类包的一个基础问题
- MyEclipse出现错误,不能运行java程序,运行出来是由tomcat网页显示出来
- 关于窗口问题
- 请问有人有tablelayout方面的资料吗?求给一份啊,或者给个链接,跪谢
- 请教高手!急!如何用java程序在链接中打开excel或word文档
- 请问Borland Enterprise Server 5.1安装好后的用户名和密码是什么?
- ★blue999star(正在学习的星星)、yeli(旗手) 来拿分啊! 谢谢!
我不知道如何利用您的代码?
你可以在你发送出去前对数据进行编码,用iso-8859-1。
我用C做过短信程序,但是我没有用JAVA做过,
你可以把你的短信程序的代码发一份给我参考一下吗?
[email protected]十分感谢!
你可以参考一下相关的标准。
gsm03.38
专门讲了编码的例子。
gsm09.10
对整个gsm讲的都很详细。
DataCoding 对应的编码。