String vipName = new String(umf.getVipName().getBytes("ISO8859-1"),"GBK");//姓名
String vipAddr = new String(umf.getVipAddr().getBytes("ISO8859-1"),"GBK");//地址
朋友和我说写这个就可以,但是谁能告诉我写在哪里,直接写在action里报错

解决方案 »

  1.   

    语法没错,估计是umf.getVipName()或者umf.getVipAddr()这里错了,或者是你数据库的编码问题
      

  2.   

    在struts里面我记得有一个过滤器的东西
    你写进去就可以了或者你写一个静态方法,存储的时候都调用一下:
    public static String fomatString(String string, String patten) {
    String result = null;
    if (string == null) {
    return null;
    }
    if (patten == null) {
    patten = "GBK";
    }
    try {
    result = new String(string.getBytes("ISO8859-1"), "GBK");
    } catch (UnsupportedEncodingException e) {
    }
    return result;
    }
      

  3.   

    算了我还是直接说情况吧
    我是s2sh的框架,我是在前台写注册的时候前台写进oracle库里的中文都变成乱码了,我不知道怎么弄大家说你们的方法也行,这个我有点整部太明白了
      

  4.   

    在struts.xml里加上 <constant name="struts.i18n.encoding" value="GBK"/>就行了
    在群里已经有人告诉我了
    谢谢大家的支持