Struts2 action返回图片流
来源:互联网 发布:快压 mac版本 编辑:程序博客网 时间:2024/05/16 12:42
备用:
struts.xml代码:
<action name="getDocumentImg" class="JcOffDocumentAction" method="getDocumentImg"><!-- 获取文档图片流 --><result type="stream"> <param name="contentType">image/jpeg</param> <param name="inputName">inputStream</param> </result> </action>
action类代码:
/** * 获取图片流 * @return */public String getDocumentImg() {model = (JcOffDocument)baseBO.load(model);String imgUrl = getAllPath(model);//String imgUrl = "/jczfoa/images/aa.jpg";if(!MyUtils.isFileExist(imgUrl, "")){//如果指定的图片不存在,显示默认图片imgUrl = getSession().getServletContext().getRealPath("/")+"images"+File.separator+"zw.jpg";}try {ByteArrayOutputStream bos = new ByteArrayOutputStream();InputStream input = new BufferedInputStream(new FileInputStream(imgUrl));byte[] bt = new byte[1024];while (input.read(bt) > 0) {bos.write(bt);}this.inputStream = new ByteArrayInputStream(bos.toByteArray());bos.close();input.close();} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}return SUCCESS;}private ByteArrayInputStream inputStream;public ByteArrayInputStream getInputStream() {return inputStream;}public void setInputStream(ByteArrayInputStream inputStream) {this.inputStream = inputStream;}
- Struts2 action返回图片流
- Struts2中Action返回Json
- struts2 ,action,返回JSON对象
- struts2 action返回json格式
- Struts2中Action的返回结果类型
- Struts2.0中Action直接返回字符串
- struts2 中action返回的类型
- Struts2里的Action返回Json数据
- Struts2中Action返回Json串
- struts2怎么设置action返回Json数据
- struts2中Action中返回Json数据
- struts2 Action层的请求 返回
- struts2中action返回"json"字符串
- Struts2.0中Action直接返回字符串
- struts2 Action如何返回到视图中
- struts2一个action返回到另一个action的特定result
- Struts2 action通过struts2返回json方法(一)
- struts2的action中返回json格式的数据
- 环城汽车赛
- myeclipse8.5 + spket1.16.23 + ExtJs4.1.1 相互配合
- nfs:server is not responding, still trying
- ibatis的sqlMapConfig.xml配置大全
- C++对象的内存布局1---基础篇----C++ 虚函数表解析
- Struts2 action返回图片流
- Project Euler problem 5
- 母牛牧场
- usaco acrobat 证明
- c++对象的内存布局2--进阶篇---C++ 对象的内存布局(上)
- mysql中int(M)中的M的含义
- 机器学习10大经典算法
- 零零散散学算法之详解RMQ & LCA
- Tools - Template list