0
我正在为我的项目使用strust2和瓷砖。这里是用于输入ID的代码(jsp)。如何在jsp中显示来自mysql的检索图像。我正在使用struts2和瓷砖
<s:textfield name="uniqueID" label="Enter Unique ID" required="required"/>
这是操作文件。
public String execute() throws Exception{
SearchDao.search(selectedID,uniqueID);
return SUCCESS;
}
的道将检索图像。
try{
.
.
.
rs = ps.executeQuery();
if(rs.next()){
InputStream originalImageStream = rs.getBinaryStream(1);
File file = new File("Retina"+".jpg");
FileOutputStream fileOutputStream = new FileOutputStream(file);
while ((length = originalImageStream.read()) != -1) {
fileOutputStream.write(length);
}
fileOutputStream.close();
}
else{
return null;
}
}
catch(Exception ex){
ex.printStackTrace();
}
return "found";
一旦图像发现,这将返回发现等操作文件将返回成功。在struts.xml中代码是
<action name="search" class="com.ActionClasses.SearchAction">
<result name="success" type="tiles"> found </result>
<result name="input" type="tiles"> search </result>
<result name="error" type="tiles"> notFound </result>
</action>
这里是tiles.xml文件。
<definition name="found" extends="home">
<put-attribute name="myTitle" value="searchSuccess"/>
<put-attribute name="myBody" value="/found.jsp"/>
</definition>
现在我怎样才能显示found.jsp检索到的图像。我在互联网上发现了一些解决方案,但仅适用于使用struts2或struts2以及休眠的项目。我没有找到使用strus2和tile的项目的解决方案。谁能帮我。谢谢。
我的问题是如何保存的图像中_bean_和_jsp_显示呢? – Pawan 2014-11-21 08:08:56
使用您找到的解决方案之一。在这种情况下,瓷砖是无关紧要的。 – 2014-11-21 10:03:11