Retrieving images using Jquery and servlet produces HTTP Status 500 error

前端 未结 1 1435
余生分开走
余生分开走 2020-12-12 05:31

I need to retrieve images from my database. For this I used jquery and servlet to retrieve all images stored in a table. But when i run the code it produces HTTP Statu

1条回答
  •  感情败类
    2020-12-12 06:21

    You included two InputStream variables in your class, which are getting set to instances of OracleBlobInputStream, which your GSON provider cannot serialize. You probably want to store the image content as bytes instead (or as a (URL encoded) string).

    public class ImageFileInfo implements Serializable {
       // Other class variables
       private byte[] thumbarray;
       private byte[] fullarray;
    
       // Constructors, Getters/Setters
    }
    
    ImageFile.setThumb(rs.getBytes("imagethumb"));
    ImageFile.setFull(rs.getBytes("imagefull"));
    

    On a side tangent, it looks like you are trying to return JSON content, but you have incorrectly specified your Content-Type as text/html, instead of application/json.

    0 讨论(0)
提交回复
热议问题