解决前台传入汉字在后台解析时会乱码

来源:互联网 发布:用ps做淘宝店招 编辑:程序博客网 时间:2024/05/04 23:00
   //将获得的名字变为比特数组然后再设置编码格式,设置utf-8通常不可以      byte[] temp;        String reportname = null;        try {            <pre name="code" class="java">     temp= name.getBytes("gb2312");            reportname = new String(temp, "GBK");        } catch (UnsupportedEncodingException e) {            e.printStackTrace();        } // 解码


0 0