/**
* File Name: ClobToString.java
*
* File Desc: 处理clob大对象类型
*
* Product AB: WEB_1_0_0
*
* Product Name: 网站
*
* Author: kan.jiang
*
* History: 2010-9-14 created by kan.jiang
*/
package com.sinitek.web.taglib.common;
import java.io.*;
import java.sql.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
/**
* 处理clob大对象类型
* @author kan.jiang
* @version 1.0
* @date 2010-9-14 9:55:33
*/
public class ClobToString extends SimpleTagSupport
{
private Object clob;
private int n;
private String addContent;
public String getAddContent()
{
return addContent;
}
public void setAddContent( String addContent )
{
this.addContent = addContent;
}
public int getN()
{
return n;
}
public void setN( int n )
{
this.n = n;
}
public Object getClob()
{
return clob;
}
public void setClob( Object clob )
{
this.clob = clob;
}
@Override
public void doTag() throws JspException, IOException
{
JspContext jc = super.getJspContext();
JspWriter out = jc.getOut();
if ( clob == null )
{
out.print( "" );
}
StringBuffer clobString = new StringBuffer();
if ( clob instanceof Clob )
{
int y;
char ac[] = new char[4096];
Reader reader;
try
{
reader = ( ( Clob ) clob ).getCharacterStream();
while ( ( y = reader.read( ac, 0, 4096 ) ) != -1 )
{
clobString.append( new String( ac, 0, y ) );
}
}
catch ( SQLException e )
{
e.printStackTrace();
}
}
else
{
clobString.append( clob.toString() );
}
if ( clobString.toString().length() > n && n > 0 )
{
out.print( clobString.toString().substring( 0, n ) + addContent );
}
else
{
out.print( clobString.toString() );
}
}
}
相关推荐
例如,将`fckeditor.js`和`fckstyles.css`等文件放在项目的公共资源目录下,然后在JSP页面中通过`<script>`和`<link>`标签引用它们。 接下来,我们需要在JSP页面中创建一个FCKeditor实例。这可以通过JavaScript实现...
15. **JSP**:涵盖 JSP 语法、session 管理、自定义标签、JSP 动作指令,以及如何通过 web.xml 文件进行配置。 16. **JDBC 高级编程**:包括通过 DataSource 获取连接、预编译语句、存储过程、事务处理、连接池以及...
WEB-INF下的applicationContext.xml为Spring的配置文件,struts-config.xml为Struts的配置文件,file-upload.jsp为文件上传页面,file-list.jsp为文件列表页面。 本文后面的章节将从数据持久层->业务层->Web层的...
4. **编写视图**:使用JSP页面作为视图展示数据。 5. **配置异常处理**:在配置文件中定义异常处理逻辑。 **Struts 1.x的配置** - **ActionServlet配置**:在`web.xml`中配置ActionServlet的初始化参数,如`...
- **Struts2标签库**: 包括各种自定义标签,用于简化JSP页面的开发。 #### 整合SSHA **SSHA** (Struts-Spring-Hibernate) 是一个常用的Java Web应用程序架构,它结合了Struts 2、Spring和Hibernate三个框架的优点...