zoukankan      html  css  js  c++  java
  • 乱码问题

    大家好:我的本地系统是WindowXP,服务器是Tomcate6,
    系统在本地机器,读取Oracle10G数据库中Blog字段时候,在JSP页面显示正常,将其发布到服务器上时,页面中Blob字段显示出现中文乱码问题,页面设置编码为UTF-8,且Blob字段在显示前,后台已经转化成String类型字符串,请问这算怎么回事?

    问题出在这里:
    public String getBlobValue(Blob blob) {
    StringBuilder sb = new StringBuilder();
    InputStream is = null;
    try {
    if (blob != null) {
    is = blob.getBinaryStream();
    byte[] buffer = new byte[1024];
    int len = 0;
    while ((len = is.read(buffer)) != -1) {
    sb.append(new String(buffer, 0, len));
    }
    }
    } catch(Exception e) {
    e.printStackTrace();
    } finally {
    try {
    is.close();
    }catch(Exception e) {
    e.printStackTrace();
    }
    }
    return sb.toString();
    }

    这是我从数据库中取出blob类型数据并转化为字符串,转完之后就是乱码,期待解决的方法

  • 相关阅读:
    简洁的Python
    python docker
    django-rest-framework笔记-类视图篇
    itertools库
    python 内置库
    python 数据分类
    python元组
    django-rest-framework笔记-请求与响应篇
    Centos 安装.NET CORE 3.1
    api接口签名验证
  • 原文地址:https://www.cnblogs.com/richelle009/p/2136600.html
Copyright © 2011-2022 走看看