标签:验证码 request public 二维码 return
/** * 获取预览活动二维码 * @author 向龙飞 * @date 2015-10-9 * @param m * @param request * @return * @throws IOException */ @RequestMapping({"/lookevent.htm"}) public void lookevent(Map<String, Object> m,HttpServletRequest request, HttpServletResponse response) throws IOException { //设置不缓存图片 response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "No-cache"); response.setDateHeader("Expires", 0); //指定生成的响应图片. response.setContentType("image/jpeg"); BufferedImage img = null; try { int duankou = request.getLocalPort(); String duan = String.valueOf(duankou); String url = "http://"+WXUtil.OAUTH_DOMAIN+":"+duan+"/getActivityDetailsForWeb.htm?activityId="+m.get("eventId")+"&isShow=1"; img = MatrixToImageWriter.getQr_imgbuffer(url, 150, 150); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } ImageIO.write(img, "jpeg", response.getOutputStream()); } 将URL生成BufferedImage类,然后使用response将图片打印到前台页面。 页面显示时只需要将图片的src属性设置为该controller的地址即可显示。
本文出自 “IdLong” 博客,请务必保留此出处http://idlong.blog.51cto.com/10631184/1708720
标签:验证码 request public 二维码 return
原文地址:http://idlong.blog.51cto.com/10631184/1708720