想了想,解决办法是对string类型的字符串进行编码,简单的是使用apache.commons.codec里的base64类,把字符串编码成base64后再传送。不过这样就要引入apache.commons.codec包,后来发现我们使用的jboss tomcat环境里tomcat本身自带的catalina.jar包里已经有base64类了。所以直接使用,搞定。测试代码
import org.apache.catalina.util.Base64;
/**
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class TestCharSet
{
public static void main(String[] args)
{
Base64 base64 = new Base64();
String temp_p="开会了";
byte[] enbytes =Base64.encode(temp_p.getBytes());
String temp=new String(enbytes);
System.out.println(temp);
String temp1=new String(Base64.decode(enbytes));
System.out.print(temp1);
}
}
/**
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class TestCharSet
{
public static void main(String[] args)
{
Base64 base64 = new Base64();
String temp_p="开会了";
byte[] enbytes =Base64.encode(temp_p.getBytes());
String temp=new String(enbytes);
System.out.println(temp);
String temp1=new String(Base64.decode(enbytes));
System.out.print(temp1);
}
}
运行结果:
v6q74cHL
开会了
上一篇: ofbiz3-entity的加载流程
下一篇: java程序,保存csdn blog的文章
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!



