/**
* 根据图片的地址,返回图片的缓冲流
* @param addr
* @return
*/
public static BufferedImage getInputStream(String addr){
try {
String imgPath = addr;
BufferedImage image = ImageIO.read(new FileInputStream(imgPath));
return image;
} catch (Exception e) {
e.printStackTrace();
System.out.println();
System.out.println("获取图片异常:java.awt.image.BufferedImage");
System.out.println("请检查图片路径是否正确,或者该地址是否为一个图片");
}
return null;
}
/**
* 根据图片的地址,来获取图片
* @param addr
* @param response
*/
@ResponseBody
@RequestMapping("/getImg")
public void getImg(@Param("addr")String addr,HttpServletResponse response){
BufferedImage img = new BufferedImage(300, 150, BufferedImage.TYPE_INT_RGB);
img = ImgUtil.getInputStream(addr);
if(img==null){
throw new RuntimeException("打印图片异常:com.controller.Business_Ctrl.getImg(String, HttpServletResponse)");
}
if(img!=null){
try {
ImageIO.write(img, "JPEG", response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
System.out.println("打印异常:com.controller.Business_Ctrl.getImg(String, HttpServletResponse)");
}
}
}
ifModified Boolean Default: false
Allow the request to be successful only if the response has changed since the last request. This is done by checking the Last-Modified header. Default value is false, ignoring the header.
cache Boolean Default: true
Added in jQuery 1.2, if set to false it will force the pages that you request to not be cached by the browser.
$.ajax({
type: "GET",
url: "static/cache.js",
dataType: "text",
cache:false,
ifModified :true
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有