JBOSS 点滴

丰丰的博客

JAVA+ORACLE+BLOB+Mybatis

实体类:
    private  byte[] richContent;
    
public byte[] getRichContent() {
        
return richContent;
    }


    
public void setRichContent(byte[] richContent) {
        
this.richContent = richContent;
    }

Mapper.xml
    <result column="RICH_CONTENT" property="richContent" jdbcType="BLOB" typeHandler="org.apache.ibatis.type.BlobTypeHandler"/>

      <if test="richContent != null" >
        UPDATE_DATE = #{richContent,jdbcType=BLOB},
      
</if>
JSP
<td class="propname">发布内容:</td>
<td class="propvalue" colspan="6">
<div id="myEditor" type="text/plain" name='content' style="width: 900px;height:400px;"/>
</td>
CONTROL保存
    //利用content转换为二进制,存入richcontent
String strRich = newsBean.getContent();
if(strRich.length()>0) {
byte[] temp = strRich.getBytes();
newsBean.setRichContent(temp);
newsBean.setContent("");
}

CONTROL显示:
if(casNewsModel.getRichContent().length>0) {
content = new String(casNewsModel.getRichContent());
casNewsModel.setContent(content);
}



posted on 2018-01-22 20:34 半导体 阅读(201) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: