struts中如何加图片并显示? <html:img scr="">应该会有这个属性的吧? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <img src="<%=你的图片的位置%>" /> 1.你在存入数据库的时候存入图片名和类型就行了(如:*.jpg/*.gif....)2.当你拿到这个名字的时候你通过 <html:img src=""/>这个标签显示~这里有个问题就是struts标签不认jsp中的<%=%>只能用<bean:write />标签来代替变量如:<html:img src="../images/<bean:write name="PicName"/>"/> 通过数据库拿出图片,需要你将你的图片数据按照二进制放入数据库或者同等效果的方法(例如BASE64编码成String),然后编写一个action,将数据按照流方式写入页面的response,然后调用该action,即返回图片的数据。然后调用方式与普通方式相同,只是图片的src写成你的action地址。采用该方式拿数据,可以效验request相关信息,例如判断session等。 Object result = actionService.service(paramMap, request); //Object是从数据库查询出来的二进制数据 if(result != null){ //页面不缓存 response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); String contentType = paramMap.get(Constants.CONTENT_TYPE_KEY); if(contentType != null) response.setContentType(contentType); String contentDisposition = paramMap.get(Constants.CONTENT_DISPOSITION_KEY); if(contentDisposition != null) response.setHeader("Content-disposition", contentDisposition); response.getOutputStream().write((byte[])result); response.getOutputStream().close(); } 调用类似这样:<html:img imageName="img${rows.userInf.userId}" action="user/iconReader.do?iconId=${rows.userInf.personUserInf.iconId}" /> java 超时控制的问题 解析xml文件问题 急问,我想点击修改到另一个页面然后确定,怎么实现 java发送邮件出现问题 java web开发发展迷惑 Apache + Weblogic??? spring <bean>元素指的是什么? 急,求特征向量的Java程序! 急!(高分求助!)请问如何实现文件传输?(最好有源码) 关于在JBUILDER7下开发EJB的问题? STRUTS的FORMFILE存储到ORACLE jsp:forward 页面间数值传送问题
2.当你拿到这个名字的时候你通过
<html:img src=""/>这个标签显示~这里有个问题就是struts标签不认jsp中的<%=%>
只能用<bean:write />标签来代替变量如:<html:img src="../images/<bean:write name="PicName"/>"/>
if(result != null){
//页面不缓存
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0); String contentType = paramMap.get(Constants.CONTENT_TYPE_KEY);
if(contentType != null)
response.setContentType(contentType);
String contentDisposition = paramMap.get(Constants.CONTENT_DISPOSITION_KEY);
if(contentDisposition != null)
response.setHeader("Content-disposition", contentDisposition);
response.getOutputStream().write((byte[])result);
response.getOutputStream().close();
}
<html:img imageName="img${rows.userInf.userId}" action="user/iconReader.do?iconId=${rows.userInf.personUserInf.iconId}" />