The Java code in the project is as follows:
@RequestMapping ("Readimage") Public voidReadimage (model, httpservletrequest request, httpservletresponse response)throwsioexception{String Magazineid= Request.getparameter ("Magazineid"); String SQL= "Select Save_path,save_name,extention from ta_horizon_info WHERE object_id = '" + Magazineid + "'"; Map<string, object> map = access.getsinglemap (sql,NULL); String Savepath= (String) map.get ("Save_path"); String Savename= (String) map.get ("Save_name"); String extention= (String) map.get ("Extention"); String FilePath= Savepath + "/" +savename + "." +extention; File Filepic=NewFile (FilePath); if(Filepic.exists ()) {FileInputStream is=NewFileInputStream (filepic); inti = is.available ();//Get File Size byteData[] =New byte[i]; Is.read (data); //Read DataIs.close (); Response.setcontenttype ("image/*");//set the returned file typeOutputStream toclient = Response.getoutputstream ();//gets the object that outputs the binary data to the clientToclient.write (data);//Output DataToclient.close (); }}
JSP page code:
<style= "width:100%; height:490px" src= "<%= Request.getcontextpath ()%>/horizon/module/magazine/readimage.wf?magazineid=${magazine.id} ">
:
Java reads the local picture and displays it on the JSP page by streaming