日期:2014-05-16 浏览次数:20414 次
JAVA后台
? ? ? ?/**
* 前台展示图片
* @throws Exception
*/
@SkipPrivilege
public void showImage() throws Exception{
String jsonString = null;
try {
if(null!=cigCode&&!"".equals(cigCode)&&null!=inoutStatus&&!"".equals(inoutStatus)){
jsonString="\"data\":{'name':'" + cigCode + "','url':'sellCigInoutSummaryQuery!outImageStream.action?cigCode="+cigCode+"&inoutStatus="+inoutStatus+"'}";
}else{
jsonString="\"data\":{'name':'" + cigCode + "','url':'images/nofoundimage.png'}";
}
} catch (Exception e) {
throw e;
}
jsonString = "{\"success\":true," + jsonString + "}";
response(jsonString);
}
/**
* 处理BLOB类型的图像流,输出到前台
* @throws Exception
*/
@SkipPrivilege
public void outImageStream() throws Exception{
Connection conn = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
Session session = null;
ServletOutputStream out =null;
BufferedInputStream imgStream =null;
try {
session = dao.getSessionFactory().openSession();
conn = session.connection();
String sql = " select t.cig_photo from t_iso_rg_sell_cig_inout t where 1=1 "
? ? ? + " and t.cig_code = ? and t.inout_status = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,cigCode);
pstmt.setString(2,inoutStatus);
rs=pstmt.executeQuery();
if (rs.next()) {
Blob photoBlob = rs.getBlob("cig_photo");?
out = response.getOutputStream();
int nSize =0;
byte[] bye;
int size = -1;
if(null!=photoBlob){
imgStream = new BufferedInputStream(photoBlob.getBinaryStream());//imgStream = ;
nSize = (int)photoBlob.length();
<