开发者社区> 问答> 正文

使用JFinal 读取 MySql BLOB 字段数据时 出现异常:报错


后台代码:

String id = this.getPara("id");

Tpl tpl = Tpl.dao.findById(id);
Tpl_Txt tpl_Txt = Tpl_Txt.dao.findById(id);
  //说明 tpl_content 是BLOB 类型 ;
String content ="";
try {
content = new String(tpl_Txt.getBytes("tpl_content"),"utf-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("===================================="+"/n"+content);
setAttr("tpl",tpl);
setAttr("tpl_context",content);


控制台信息:

====================================/n<!DOCTYPE html>
<html>


<head>


  <meta charset="UTF-8">

    //出现乱码
  <title>HTML5 Canvas????Ч???????????ЧDEMO???</title>


  <link rel="stylesheet" href="css/normalize.css">


    <link rel="stylesheet" href="css/style.css" media="screen" type="text/css" />


</head>


<body>
<div style="text-align:center;clear:both;position:absolute;top:0;left:260px">
<script src="/gg_bd_ad_720x90.js" type="text/javascript"></script>
<script src="/follow.js" type="text/javascript"></script>
</div>
<canvas class="canvas"></canvas>


<div class="help">?</div> 


<div class="ui">
  <input class="ui-input" type="text" />
  <span class="ui-return">?</span>
</div>


<div class="overlay">
  <div class="tabs">
    <div class="tabs-labels"><span class="tabs-label">Commands</span><span class="tabs-label">Info</span><span class="tabs-label">Share</span></div>


    <div class="tabs-panels">
      <ul class="tabs-panel commands">
        <li class="commands-item"><span class="commands-item-title">Text</span><span class="commands-item-info" data-demo="Hello :)">Type anything</span><span class="commands-item-action">Demo</span></li>
        <li class="commands-item"><span class="commands-item-title">Countdown</span><span class="commands-item-info" data-demo="#countdown 10">#countdown<span class="commands-item-mode">number</span></span><span class="commands-item-action">Demo</span></li>
        <li class="commands-item"><span class="commands-item-title">Time</span><span class="commands-item-info" data-demo="#time">#time</span><span class="commands-item-action">Demo</span></li>
        <li class="commands-item"><span class="commands-item-title">Rectangle</span><span class="commands-item-info" data-demo="#rectangle 30x15">#rectangle<span class="commands-item-mode">width x height</span></span><span class="commands-item-action">Demo</span></li>
        <li class="commands-item"><span class="commands-item-title">Circle</span><span class="commands-item-info" data-demo="#circle 25">#circle<span class="commands-item-mode">diameter</span></span><span class="commands-item-action">Demo</span></li>


        <li class="commands-item commands-item--gap"><span class="commands-item-title">Animate</span><span class="commands-item-info" data-demo="The time is|#time|#countdown 3|#icon thumbs-up"><span class="commands-item-mode">command1</span> |<span class="commands-item-mode">command2</span></span><span class="commands-item-action">Demo</span></li>
      </ul>


      <div class="tabs-panel ui-details">
        <div class="ui-details-content">
          <h1>Shape Shifter</h1>
          <p>
            An experiment by <a href="//www.kennethcachia.com" target="_blank">Kenneth Cachia<a/>.<br/>
            <a href="//fortawesome.github.io/Font-Awesome/#icons-new" target="_blank">Font Awesome</a> is being used to render all #icons.
          </p>


          <br/><p>Visit <a href="http://www.kennethcachia.com/shape-shifter/?a=#icon thumbs-up" target="_blank">Shape Shifter</a> to use icons.</p>
        </div>
      </div>


      <div class="tabs-panel ui-share">
        <div class="ui-share-content">
          <h1>Sharing</h1>
          <p>Simply add <em>?a=</em> to the current URL to share any static or animated text. Examples:</p>
          <p>
            <a href="http://www.kennethcachia.com/shape-shifter?a=Hello" target="_blank">www.kennethcachia.com/shape-shifter?a=Hello</a><br/>
            <a href="http://www.kennethcachia.com/shape-shifter?a=Hello|#countdown 3" target="_blank">www.kennethcachia.com/shape-shifter?a=Hello|#countdown 3</a>
          </p>
        </div>
      </div>
    </div>
  </div>
</div>


  <script src="js/index.js"></script>


</body>


</html>

返回页面信息出现:

<tr>
<td class="value" colspan="4"><input name="tpl_Txt.tpl_content" type="text"
id="name" class="easyui-textbox" style="width:780px;" value="${tpl_context}"
data-options="height:'auto',multiline:true" /></td>
</tr>

1.请高手们,帮看看,从数据库读取BLOB ,方法是否妥当? 

2.望诸位高手,神级人物,教我 机种靠谱 的处理 BLOB ,CLOB 读取方法
3.在前台数据读取时候,出现如图所示,情况:





展开
收起
kun坤 2020-06-06 16:15:55 909 0
1 条回答
写回答
取消 提交回答
  • @JFinal######格式化文本######

    你这种是字符乱码..看你获取的时候用了utf-8  那么你存的时候是用什么格式存的..

    还有页面编码是啥.. 检查一下就好... 

    2020-06-06 16:16:01
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
One Box: 解读事务与分析一体化数据库 HybridDB for MySQL 立即下载
One Box:解读事务与分析一体化数据库HybridDB for MySQL 立即下载
如何支撑HTAP场景-HybridDB for MySQL系统架构和技术演进 立即下载

相关镜像