日期:2014-05-17 浏览次数:20670 次
public class MyCaptcha extends ActionSupport implements SessionAware { @SuppressWarnings("rawtypes") private Map session; @SuppressWarnings("rawtypes") public void setSession(Map session) { this.session = session; } @Override public String execute() throws Exception { System.out.println("action被执行————————————————————————————————"); HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("image/png"); response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); ServletOutputStream outputStream = response.getOutputStream(); Captcha captcha = new Captcha(); captcha.generateImage(this.session, outputStream); outputStream.close(); return NONE; } }