注册 登录
编程论坛 J2EE论坛

谁有空啊,帮我看看,谢谢

caihua 发布于 2013-05-23 14:30, 969 次点击
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
7 回复
#2
caihua2013-05-23 14:30
为什么一点注册链接不过去,就变成这样了
#3
博望、小五2013-05-23 15:44
回复 2楼 caihua
你Severlet写错了,获取不到
#4
caihua2013-05-24 20:13
回复 3楼 博望、小五
那要怎样写啊,我写了好多个
#5
樊佑剑2013-05-25 07:23
回复 4楼 caihua
您的源代码可以发过来吗
#6
caihua2013-05-25 16:42
程序代码:
package import *;
import *;

public class CodingConvert {

  public CodingConvert() {}

  public static String sqlConvert(String sql) throws
      UnsupportedEncodingException {

    return convertEncoding(sql, "GBK", "ISO-8859-1");
  }

  /**
   * 将ISO-8859-1字符集转化为gb2312字符集
   *
@param srcText 源字符串
   *
@return destText 目标字符串
   *
@throws UnsupportedEncodingException 不支持字符集异常
   
*/
  public static String isoToGBK(String srcText) throws
      UnsupportedEncodingException {
    return convertEncoding(srcText, "ISO-8859-1", "GBK");

  }

  /**
   * 将gb2312字符集转化为ISO-8859-1字符集
   *
@param srcText 源字符串
   *
@return destText 目标字符串
   *
@throws UnsupportedEncodingException 不支持字符集异常
   
*/
  public static String GBKToIso(String srcText) throws
      UnsupportedEncodingException {
    try {
      return convertEncoding(srcText, "GBK", "ISO-8859-1");
    }
    catch (UnsupportedEncodingException e) {
      e.printStackTrace();
      return srcText;
    }
  }

  /**
   * 代码字符集转换
   *
@param str 原始字符串
   *
@param sourEncoding 源代码字符集
   *
@param destEncoding 目标代码字符集
   *
@return result 转换后字符串
   *
@throws UnsupportedEncodingException 不支持字符集异常
   
*/
  public static String convertEncoding(String str,
                                       String sourEncoding,
                                       String destEncoding) throws
      UnsupportedEncodingException {

    if (str == null || str.equals(""))
      return "";
    int convertNum = 0;
    char[] inputChars = new char[str.length()];
    CharToByteConverter ctbConverter = (CharToByteConverter)
        CharToByteConverter.getConverter(sourEncoding);
    ctbConverter.setSubstitutionMode(false);
    for (int i = 0; i < str.length(); i++) {
      if (ctbConverter.canConvert(str.charAt(i))) {
        inputChars[convertNum++] = str.charAt(i);
      }
      else {
        if (ctbConverter.canConvert(str.charAt(i))) {
          inputChars[convertNum++] = str.charAt(i);
        }
        else {
          return str;
        }
      }
    }
    byte[] outputBytes = new byte[inputChars.length * 2];
    try {
      int count = ctbConverter.convert(inputChars, 0, inputChars.length,
                                       outputBytes, 0, outputBytes.length);
    }
    catch (Exception e) {
      System.out.println("1");
      e.printStackTrace();
    }

    ByteToCharConverter btcConverter = ByteToCharConverter.getConverter(
        destEncoding);

    char[] outputChars = new char[outputBytes.length];
    try {
      int count = btcConverter.convert(outputBytes, 0, outputBytes.length,
                                       outputChars, 0, outputChars.length);
    }
    catch (Exception e) {
      System.out.println("2");
      e.printStackTrace();
    }

    String result = new String(outputChars);
    return result.trim();
  }
}
#7
caihua2013-05-25 16:47
回复 5楼 樊佑剑
我想让denglu.jsp和zhuce.jsp连接上
只有本站会员才能查看附件,请 登录
#8
ee29066822013-05-30 00:12
项目没发布到服务器
1