转码
package com.bjbg.util;import java.io.PrintStream;public class EncodeBean
{ public EncodeBean()
{
} public static String changeCode(String s)
{
String s1 = null;
try
{
if(s == null)
return null;
s1 = new String(s.getBytes("ISO8859_1"), "GB2312");
}
catch(Exception exception)
{
System.out.println("Exception in changeCode: " + exception);
}
return s1;
}
public static String canCode(String s)
{
String s1 = null;
try
{
if(s == null)
return null;
s1 = new String(s.getBytes("GB2312"), "ISO8859_1");
}
catch(Exception exception)
{
System.out.println("Exception in changeCode: " + exception);
}
return s1;
}}
使用上面的BEAN
<%datas="????????????"%>
<%=EncodeBean.changeCode(datas)%>
package com.bjbg.util;import java.io.PrintStream;public class EncodeBean
{ public EncodeBean()
{
} public static String changeCode(String s)
{
String s1 = null;
try
{
if(s == null)
return null;
s1 = new String(s.getBytes("ISO8859_1"), "GB2312");
}
catch(Exception exception)
{
System.out.println("Exception in changeCode: " + exception);
}
return s1;
}
public static String canCode(String s)
{
String s1 = null;
try
{
if(s == null)
return null;
s1 = new String(s.getBytes("GB2312"), "ISO8859_1");
}
catch(Exception exception)
{
System.out.println("Exception in changeCode: " + exception);
}
return s1;
}}
使用上面的BEAN
<%datas="????????????"%>
<%=EncodeBean.changeCode(datas)%>
解决方案 »
- 要用到foreach这些标签的时候,XML中应该怎么配
- Spring MVC 3中VIEW和Controller的疑惑。
- 请各位高人帮忙指导小弟一下java的webservice 如何开发及部署,
- 请教各位正在从事JAVA方向的工作的大人
- 求助一个JavaScript的问题,字符串操作的~~
- 求代码,忘高手帮忙!
- 在线等 ,怎样用 JSP 调用另一个 JSP啊,我以前看到过,忘了,请帮忙。。
- 一个JSP发送邮件的问题,需要高手的帮助!
- java 乱码问题求帮助啊
- 本人做了一个向ACCESS数据库中存储数据的JSP程序段,实行用户注册存储的,哪位大侠帮我看看错!一定加分
- 如何从数据库中读出图片?
- 从哪能下载resin???
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("GBK");
String temp=new String(temp_t,"ISO8859_1");
return temp;
}
catch(Exception e)
{}
return "null";
}
%>
<%
String aa='中文';
cstmt.setString(1,getStr(aa));
%>
cstmt.setString(1,new String('中文'.getBytes("ISO-8859-"),"GB2312");
JSP中文化论坛