Read Clob/BLOB and struts2clob from the struts2 front-end page
When the Clob attribute value of an object is displayed through the Struts2 tag, the value of the toString method is displayed instead of the CLOB or BLOB content.
For example, the annotation in my object is:
@Lob@Column(name = "CONTENT_TEXT")public String getContentText() {return contentText;}
Front-end page reading method:
<s:property value="#entry.contentText" />
The result is as follows:
oracle.sql.CLOB@1077e76
To properly display CLOB or BLOB content. The clob or blob conversion method must be added to the action.
public String getClob(Clob c){Reader reader = null;StringBuffer sb = new StringBuffer();try {reader = c.getCharacterStream();BufferedReader br = new BufferedReader(reader);String temp = null;while ((temp=br.readLine()) != null) {sb.append(temp);}} catch (Exception e) {}finally{if (reader!=null) {try {reader.close();} catch (IOException e) {}}} return sb.toString();}The frontend page call is changed
<s:property value="%{getClob(#entry.contentText)}" /></span>
In this way, the clob content can be normally displayed. blob is similar, but the reading method is changed to binary stream reading.
Struts2 reads blob data (image) from the database)
1. Reader rd = rs. getCharacterStream (1); and Blob blob = rs. getBlob (1); 1 represents the column number, indicating that it will return data from the first column
2. Only one image is displayed on your front-end. That's because your SQL language restricts the use of only one image: select GoodsImage from table_goods where GoodTypeID = 1
Struts2 reading data from the database
Get the data you need in the action, put it in the action class attribute, and add the public access method. After the action is executed, it jumps to the page, you can directly use $ {} or <s: property> to access this property.
I don't think you have any basic concepts...