gpt4 book ai didi

java - 如何使用 json 从 REST Web 服务检索图像

转载 作者:行者123 更新时间:2023-12-02 06:57:40 26 4
gpt4 key购买 nike

这是我的 Web 服务数据库操作,如果我注释 blob 字段行意味着它工作正常。我获取 json 字符串。但我想将 tat 图像带到我的 jsp 页面。我怎样才能实现这个目标?

     @GET
@Produces("application/json")
@Path("/")
public String getJson(@QueryParam("appno") int appno) {
app_be.setCus_first_name( rs.getString("cus_first_name"));
app_be.setCus_last_name(rs.getString("cus_last_name"));
app_be.setApplication_num(rs.getInt("aplication_num"));
app_be.setResi_address(rs.getString("resi_address"));
app_be.setWork_place_address(rs.getString("work_place_address"));
app_be.setRenewaldate(rs.getDate("app_date"));
app_be.setProfession(rs.getString("profession"));
app_be.setPhoto(rs.getBlob("photo"));
app_be.setPhone_number(rs.getString("phone_number"));
app_be.setMobile_num(rs.getString("mobile_num"));
app_be.setMembership_type(rs.getString("membership_type"));
app_be.setMembership_cycle(rs.getString("membership_cycle"));
app_be.setEmail(rs.getString("email"));
app_be.setDueamt("1002");
app_be.setDesignation("designation");
app_be.setDebitbal("100022");
app_be.setCreditlimit("credilimt");
app_be.setAge(rs.getInt("age"));
app_be.setSex(rs.getString("sex"));
}
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = ow.writeValueAsString(app_be);
retrun json;

最后一行在这个转换 blob 字段中给出 json 字符串不包括意味着它转换并给出 json 字符串,否则它显示错误,因为 objectwriter 无法将 blob 写为 json 字符串,所以请给出想法将我的图像带到我的 jsp 或来自这个 Restful Web 服务的 servlet。请帮忙。

最佳答案

单独加载图像,将图像的src属性更改为指向正确返回图像的servlet的URL。

关于java - 如何使用 json 从 REST Web 服务检索图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17105894/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com