数据库 图片展示Java代码

图片展示struts

<action name="getDoctorImage" class="communityAction" method="getDoctorImage">
<result name="success" type="stream">
<param name="contentType">image/jpeg</param>
<param name="inputName">is</param> 
<param name="bufferSize">4096</param>
</result> 
</action>


图片展示Controller

private InputStream  is;

private TbWebsiteCommunityDoctor tcd;

public String getDoctorImage() throws IOException{
List list=new ArrayList();
list=webService.findCommunityDepartDoctorDetail(Long.valueOf(doctorId));//通过id读取数据内容
tcd=(TbWebsiteCommunityDoctor)list.get(0);
byte[] image = (byte[]) tcd.getImage();//从中获取需要展示的图片
is = new ByteArrayInputStream(image);
return SUCCESS;
}


图片展示 jsp

<td colspan="2">
<div id="oldImage" class="new_wenzi">
<s:if test="dphotoImage.length != 0">
<img src="getTopDoctorImageCurrent.action?did=<s:property value="did"/>"  align="absmiddle" />
</s:if>
</div> 
</td>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Thymeleaf中展示Java图片,您可以使用Thymeleaf的属性th:src来指定的路径。根据引用提供的代码片段,可以看到使用th:src="@{/file/download?(filename=${product.getPic()})}"来展示图片。在这个代码中,${product.getPic()}是一个动态的表达式,它返回图片的文件名。这个代码片段假设有一个名为"file/download"的映射路径,它可以根据文件名加载对应的图片。因此,当Thymeleaf渲染这个页面时,它会替换th:src中的动态表达式为实际的图片路径。通过这种方式,您可以在页面上展示Java图片。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [基于thymeleaf实现数据库图片展示到浏览器表格](https://blog.csdn.net/weixin_43356538/article/details/124085450)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [java springboot+thymeleaf 实现图片上传并展示到页面当中](https://blog.csdn.net/ziyue13/article/details/124027157)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值