数据库为mssql zp字段为image类型

java代码

 OutputStream out = null;
try
{
String contenttype = "image/jpeg";
ActionContext context = ActionContext.getContext();
// HttpServletRequest request = (HttpServletRequest) context.get(ServletActionContext.HTTP_REQUEST);
HttpServletResponse response = (HttpServletResponse) context.get(ServletActionContext.HTTP_RESPONSE); response.setContentType(contenttype);
out = response.getOutputStream();
Statement stmt=con.createStatement();
String sql="select top 1 zp from table_1 ";
ResultSet rs=stmt.executeQuery(sql);
//byte []by =rs.getBytes(0);
while(rs.next()){
out.write(rs.getBytes("ZP"));
}
}
catch(SQLException ee){ }
finally {
out.flush();
out.close();
}

struts.xml

<action name="bb" class="test.tt" method="getimage2">
</action>

index.jsp

 <img name="inputName"  id="inputName" src="bb.action"/>

struts2 action 返回图片流的更多相关文章

  1. Web Api 返回图片流

    public class TestController : ApiController { public HttpResponseMessage GetImg() { //获取文件的绝对路径 stri ...

  2. Web Api 返回图片流给前端

    public class TestController : ApiController { public HttpResponseMessage GetImg() { //获取文件的绝对路径 stri ...

  3. struts通过action返回json

    其实struts2通过action返回json挺简单的,但是就是老要忘,所以索性写在博客上.好的,开始. 首先是引入必须的jar包: struts2-json-plugin-2.3.24.jar 然后 ...

  4. Struts2 Action中动态方法调用、通配符的使用

    一.Struts2执行过程图: 二.struts2配置文件的加载顺序 struts-default.xml---struts-plugin.xml---struts.xml 具体步骤: 三.Actio ...

  5. JsonResult作为Action返回值时的错误

    JsonResult作为Action返回值时的错误   System.InvalidOperationException: This request has been blocked because ...

  6. Java Hour 32 Weather ( 5 ) struts2 – Action class

    有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. Hour 32 Struts2 Action 1 将action 映射到 ac ...

  7. 【MVC】关于Action返回结果类型的事儿(上)

    一. ASP.NET MVC 1.0 Result 几何? Action的返回值类型到底有几个?咱们来数数看. ASP.NET MVC 1.0 目前一共提供了以下十几种Action返回结果类型: 1. ...

  8. SWFUpload接受服务器Action返回的参数

    首先我们要了解这个函数 function uploadSuccess(file, serverData) { try { var progress = new FileProgress(file, t ...

  9. MVC Action 返回类型[转]

    一.         ASP.NET MVC 1.0 Result 几何? Action的返回值类型到底有几个?咱们来数数看. ASP.NET MVC 1.0 目前一共提供了以下十几种Action返回 ...

随机推荐

  1. ArchLinux安装与配置小结

    最近无意间发现一个基于ArchLinux的发行版--BlackArch,主题十分炫酷(中二).当然渗透类的Linux 发行版已经有BackTrack和Kali了,不过都是源于Debian的,使用者众多 ...

  2. Qt之界面出现、消失动画效果(简单好用)

    在学习Qt的这2.3个月里,对Qt越发感兴趣,从刚开始的盲目.无所适从到现在的学习.研究.熟练.掌握的过程中,我学到了很多东西,也学会了如何通过自学让自己更加成熟.强大起来,如何更有效地提高自己学习. ...

  3. [iOS]ios archives 出现的是other items而不是iOS Apps的解决方案

    百度了一上午, 总是这样子. (利用cocoapods上传项目的时候, 总是这样无法点击UpLoad to App Store) 然后. 这样做. 就可以了!

  4. Pipeline aborted due to error

    报错内容 x. Pipeline aborted due to error {:exception=>"LogStash::ConfigurationError", ... ...

  5. Linux命令-tr

    tr命令用于转换文本文件中的字符 [root@localhost test]# cat .txt abcdefg asdfoui asdfqer [root@localhost test]# cat ...

  6. 【转载】【JQuery学习】jQuery插件开发

    JQuery做得最好的就是他的闭包和扩展性.超级简单的扩展方法,让更多的人可以轻松的开发定制自己的jQuery插件.下面的东西是转载过来当做学习材料的.虽然貌似有点古老,但是jQuery的变更一直都不 ...

  7. SSIS ->> Control Flow And Data Flow

    In the Control Flow, the task is the smallest unit of work, and a task requires completion (success, ...

  8. php监听客户端连接状态

    http://bbs.csdn.net/topics/390661022 http://www.poluoluo.com/jzxy/201207/169977.html http://zhidao.b ...

  9. Excel有用的宏

    =Index({"同事","同学","亲戚"},b3) 前面的array默认索引从1开始. 如果b3为1.而枚举数组是: 0=>同事, ...

  10. Android:在eclipse中快速多行注释的方法

    http://blog.csdn.net/jianghuiquan/article/details/8534337 也许你能够记住以下部分快捷键,对你开发和设计过程中大裨益! 1.//注释添加和取消 ...