package com.zbkj.crmeb.test.controller;
import com.utils.VerifyCodeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
@RestController
public class HelloWorldController {
@Resource
private HttpServletResponse response;
@RequestMapping("/helloImage")
public void helloImage(){
try {
BufferedImage image = ImageIO.read(new FileInputStream(new File("D:\\chrome.png")));
response.setContentType("image/png");
OutputStream os = response.getOutputStream();
if (image != null) {
ImageIO.write(image, "png", os);
}
os.flush();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}