How to display an image using tag in JSP

前端 未结 2 1457
挽巷
挽巷 2020-12-22 10:07

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 dis

相关标签:
2条回答
  • 2020-12-22 10:36

    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.

    See also How can we display dynamic or static images that can be provided as an array of bytes, and How to display image in Struts2.

    0 讨论(0)
  • 2020-12-22 10:57

    You should do it in struts 2 way by implementing a Custom Result Type to display image on the JSP.

    Here is an Example for displaying dynamic image in Stuts2.

    It creates a custom result type by implementing Result interface.

    public class CustomImageBytesResult implements Result {
    .
    .
    .
    }
    
    0 讨论(0)
提交回复
热议问题