<tfoot id='oHUkJ'></tfoot>

    <small id='oHUkJ'></small><noframes id='oHUkJ'>

    1. <i id='oHUkJ'><tr id='oHUkJ'><dt id='oHUkJ'><q id='oHUkJ'><span id='oHUkJ'><b id='oHUkJ'><form id='oHUkJ'><ins id='oHUkJ'></ins><ul id='oHUkJ'></ul><sub id='oHUkJ'></sub></form><legend id='oHUkJ'></legend><bdo id='oHUkJ'><pre id='oHUkJ'><center id='oHUkJ'></center></pre></bdo></b><th id='oHUkJ'></th></span></q></dt></tr></i><div id='oHUkJ'><tfoot id='oHUkJ'></tfoot><dl id='oHUkJ'><fieldset id='oHUkJ'></fieldset></dl></div>
        • <bdo id='oHUkJ'></bdo><ul id='oHUkJ'></ul>

        <legend id='oHUkJ'><style id='oHUkJ'><dir id='oHUkJ'><q id='oHUkJ'></q></dir></style></legend>

        如何在 JSP 中使用标签显示图像

        How to display an image using tag in JSP(如何在 JSP 中使用标签显示图像)

            <small id='OOXcm'></small><noframes id='OOXcm'>

            • <bdo id='OOXcm'></bdo><ul id='OOXcm'></ul>

              <i id='OOXcm'><tr id='OOXcm'><dt id='OOXcm'><q id='OOXcm'><span id='OOXcm'><b id='OOXcm'><form id='OOXcm'><ins id='OOXcm'></ins><ul id='OOXcm'></ul><sub id='OOXcm'></sub></form><legend id='OOXcm'></legend><bdo id='OOXcm'><pre id='OOXcm'><center id='OOXcm'></center></pre></bdo></b><th id='OOXcm'></th></span></q></dt></tr></i><div id='OOXcm'><tfoot id='OOXcm'></tfoot><dl id='OOXcm'><fieldset id='OOXcm'></fieldset></dl></div>
            • <tfoot id='OOXcm'></tfoot>

              1. <legend id='OOXcm'><style id='OOXcm'><dir id='OOXcm'><q id='OOXcm'></q></dir></style></legend>

                  <tbody id='OOXcm'></tbody>

                1. 本文介绍了如何在 JSP 中使用标签显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是在动作类中检索图像的代码.我试过了,但无法显示它我不知道图像处理.JSP中如何使用标签来显示图片?

                  Here is the code to retrieve image in action class. I have tried it, but not able to display it I don't know about the image processing. How should I use tags in JSP to display the image?

                  public String displayImage()
                    {
                      Connection con = null;
                      PreparedStatement preparedStatement = null;
                      ResultSet resultSet = null;
                      String sql,result="";
                      con=JdbcHelper.getConnection();
                      if(con!=null)
                      {
                        try
                        {
                          sql = "SELECT INPUT_FILE_BLOB FROM message_details where message_id=?";
                          preparedStatement = con.prepareStatement(sql);
                          preparedStatement.setString(1, messageid);
                          resultSet = preparedStatement.executeQuery();
                          if(resultSet.next())
                          {
                            Blob image = resultSet.getBlob("INPUT_FILE_BLOB");
                            System.out.println("=============Image2
                  " +image);
                            int len1 = (int) image.length();
                            System.out.println("=============len1
                  " +len1);
                            byte [] rb1 = new byte[len1];
                            InputStream readImg1 = resultSet.getBinaryStream(1);
                            try {
                              int index1=readImg1.read(rb1, 0, len1);
                              System.out.println("index1"+index1);
                              response.reset();
                              response.setContentType("image/jpg");
                              response.getOutputStream().write(rb1,0,len1);
                              response.getOutputStream().flush();
                            } catch (IOException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                            }
                          }
                        }
                        catch(SQLException e)
                        {
                          try
                          {
                            con.rollback();
                          }
                          catch (SQLException e1)
                          {
                            result = e1.getMessage();
                            e.printStackTrace();
                          }
                          result = e.getMessage();
                          e.printStackTrace();
                        }
                        finally
                        {
                          JdbcHelper.close(resultSet);
                          JdbcHelper.close(preparedStatement);
                          JdbcHelper.close(con);
                        }
                      }
                      else
                        result = Constants.SUCCESS;
                  
                    }
                  

                  推荐答案

                  从数据库中检索图像作为 Blob 或字节数组后,您将直接写入响应.在这种情况下,您不应该返回 SUCCESS 结果,您需要返回 NONE 结果.然后在 JSP 中,您可以使用 img 标记将图像作为单独的线程访问,该标记将调用您返回图像的操作.

                  After retrieving an image from the database as Blob or byte array you are writing direct to response. In this case you should not return SUCCESS result, you need to return NONE result. Then in the JSP you could access an image as a separate thread using img tag that will call your action that return an image.

                  另见我们如何显示动态或可以作为字节数组提供的静态图像,和如何在Struts2中显示图像.

                  这篇关于如何在 JSP 中使用标签显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Java Bytecode Manipulation Library Suggestions(Java 字节码操作库建议)
                  Java CLI UI-design: frameworks or libraries?(Java CLI UI 设计:框架还是库?)
                  About the use of Beans.xml configuration file in Spring Framework application(关于Spring Framework应用中Beans.xml配置文件的使用)
                  What is the difference between Spring, Struts, Hibernate, JavaServer Faces, Tapestry?(Spring、Struts、Hibernate、JavaServer Faces、Tapestry 有什么区别?)
                  Are there any android application framework like spring?(有没有像spring这样的android应用程序框架?)
                  Java Swing based game framework. Any advice?(基于 Java Swing 的游戏框架.有什么建议吗?)
                    <bdo id='1yfbr'></bdo><ul id='1yfbr'></ul>

                  • <tfoot id='1yfbr'></tfoot>

                      • <i id='1yfbr'><tr id='1yfbr'><dt id='1yfbr'><q id='1yfbr'><span id='1yfbr'><b id='1yfbr'><form id='1yfbr'><ins id='1yfbr'></ins><ul id='1yfbr'></ul><sub id='1yfbr'></sub></form><legend id='1yfbr'></legend><bdo id='1yfbr'><pre id='1yfbr'><center id='1yfbr'></center></pre></bdo></b><th id='1yfbr'></th></span></q></dt></tr></i><div id='1yfbr'><tfoot id='1yfbr'></tfoot><dl id='1yfbr'><fieldset id='1yfbr'></fieldset></dl></div>

                        <small id='1yfbr'></small><noframes id='1yfbr'>

                          <tbody id='1yfbr'></tbody>
                            <legend id='1yfbr'><style id='1yfbr'><dir id='1yfbr'><q id='1yfbr'></q></dir></style></legend>