1、jspimg alt="test" src="getImg2.do"2、controller @RequestMapping("getImg2") public void getImg2(HttpServletRequest...
1、jsp
<img alt="dGVzdA==" src="Z2V0SW1nMi5kbw==">
2、controller
@RequestMapping("getImg2")
public void getImg2(HttpServletRequest request, HttpServletResponse response)
throws IOException {
FileInputStream fis = null;
OutputStream os = null;
try {
fis = new FileInputStream("d:/log.png");
os = response.getOutputStream();
int count = 0;
byte[] buffer = new byte[1024 * 8];
while ((count = fis.read(buffer)) != -1) {
os.write(buffer, 0, count);
os.flush();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fis.close();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
以上这篇img的src地址是一个请求的方式来显示图片方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
沃梦达教程
本文标题为:img的src地址是一个请求的方式来显示图片方法
猜你喜欢
- 基于Java Agent的premain方式实现方法耗时监控问题 2023-06-17
- JSP 制作验证码的实例详解 2023-07-30
- 深入了解Spring的事务传播机制 2023-06-02
- Java实现顺序表的操作详解 2023-05-19
- SpringBoot使用thymeleaf实现一个前端表格方法详解 2023-06-06
- JSP页面间传值问题实例简析 2023-08-03
- ExecutorService Callable Future多线程返回结果原理解析 2023-06-01
- Spring Security权限想要细化到按钮实现示例 2023-03-07
- Springboot整合minio实现文件服务的教程详解 2022-12-03
- Java中的日期时间处理及格式化处理 2023-04-18