Macos osx web服务在绘制图像时在任务栏-osx-中生成图标
我有一个显示字符串图像的web端点。。。当运行以下代码(在tomcat中)时,它会在OSX的任务栏中生成一个java图标。不确定这是否是一个问题,或者发生了什么。寻找某种解释Macos osx web服务在绘制图像时在任务栏-osx-中生成图标,macos,spring-boot,web-services,Macos,Spring Boot,Web Services,我有一个显示字符串图像的web端点。。。当运行以下代码(在tomcat中)时,它会在OSX的任务栏中生成一个java图标。不确定这是否是一个问题,或者发生了什么。寻找某种解释 @RequestMapping("/text/{text}") public void textImage(HttpServletResponse response, @PathVariable("text") String text){ response.setContentType("image/png");
@RequestMapping("/text/{text}")
public void textImage(HttpServletResponse response, @PathVariable("text") String text){
response.setContentType("image/png");
try{
OutputStream os = response.getOutputStream();
BufferedImage bufferedImage = new BufferedImage( (text.length()*10) , 14, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = bufferedImage.createGraphics();
g2d.setBackground(Color.WHITE);
g2d.setPaint(Color.BLACK);
Font font = new Font("sansserif", Font.PLAIN, 12);
g2d.setFont(font);
g2d.drawString(text, 0, 12);
ImageIO.write(bufferedImage, "png", os);
} catch(Exception e) {
// nothing we can do, simply log the error
logger.error("Could not draw string: ", e);
}
}
默认情况下,当您使用图形时,您将获得一个窗口服务器连接(无论您是否实际渲染到屏幕)。你可以用它来避免它