Recently need to traverse a JSP page above a number of pictures, usually do more is a string integer and other types of traversal, the picture is binary and the original commonly used types are very different.
Bbfseal.java
public class Bbfseal {
Private Blob content;
Private String ID;
private String name;
Private Bbfuseruser;
Private Blob imageseal;
Public Bbfseal ()
{
}
Public Bbfseal (Blob imageseal, String ID) {
Super ();
This.imageseal = Imageseal;
This.id = ID;
}
Public String GetName () {
return name;
}
public void SetName (String name) {
THIS.name = name;
}
public void SetContent (Blob content) {
this.content = content;
}
Public Blob getcontent () {
return content;
}
public void SetId (String id) {
This.id = ID;
}
Public String getId () {
return ID;
}
public void SetUser (Bbfuser user) {
This.user = user;
}
Public Bbfuser GetUser () {
return user;
}
Public Blob Getimageseal () {
return imageseal;
}
public void Setimageseal (Blob imageseal) {
This.imageseal = Imageseal;
}
}
The main code in the action
/**
* Find all the stamps according to the user ID
*/
Public String showseallist () {
HttpServletRequest request = Servletactioncontext.getrequest ();
Bbfuser user = (Bbfuser) request.getsession (). getattribute ("user");
String uid = User.getid ();
This.bbfseals = This.manage.listSeals (UID);
return "Toseallist";
}
/**
* Display photo Information
*/
Public String Showseal () {
Bbfseal seal = manage.loadseal (ID);
Instantiates a byte array stream, storing the photo bytes in the table
InputStream = new Bytearrayinputstream (blobtobinaryutils
. Blobtobinary (Seal.getimageseal ()));
Return "Success";
}
Struts.xml
<action name= "Sealselect" method= "Showseallist"
class= "Sealselect" >
<result name= "Toseallist" >toseal.jsp</result>
</action>
<action name= "Showseal" method= "Showseal"
class= "Sealselect" >
<result name= "Success" type= "Stream" >
<!--type= "stream" is used for output binary streams in file downloads
<param name= "ContentType" ></param>
--><param name= "BufferSize" >1024</param>
</result>
</action>
TOSEAL.JSP Core Code
</tr>
<s:iterator value= "Bbfseals" >
<tr >
<td><a data-role= "button" data-mini= "true" value= ' id '/> '); " >
<!--display photo information, SRC Specify action and pass in ID-
</a></td>
</tr>
</s:iterator>
<tr>
public class Blobtobinaryutils {
public static byte[] Blobtobinary (blob blob) {
InputStream is = null;
Byte[] B = null;
try {
is = Blob.getbinarystream ();
b = new byte[(int) blob.length ()];
Is.read (b);
return b;
} catch (Exception e) {
E.printstacktrace ();
} finally {
try {
Is.close ();
is = null;
} catch (Exception e) {
E.printstacktrace ();
}
}
return b;
}
}