首页>代码>spring+spring mvc+mybatis开发的java客户关系管理系统,前端采用easyui编写>/ssm-crm-new - 副本/src/com/crm/controller/CodeController.java
package com.crm.controller;

import java.io.IOException;

import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.crm.util.common.RandomCodeUtil;

/**
 * 
 * @author zh
 *
 */
@Controller
public class CodeController {
	
	@RequestMapping("/code") 
    public void getCode(HttpServletRequest req, HttpServletResponse resp) throws IOException { 
		RandomCodeUtil rdnu = RandomCodeUtil.Instance();
		HttpSession session = req.getSession(); 
		// 取得随机字符串放入Session中
		session.setAttribute("RANDOMCODE", rdnu.getString());
		
		// 禁止图像缓存。  
        resp.setHeader("Pragma", "no-cache"); 
        resp.setHeader("Cache-Control", "no-cache"); 
        resp.setDateHeader("Expires", 0); 
 
        resp.setContentType("image/jpeg"); 
 
        // 将图像输出到Servlet输出流中。  
        ServletOutputStream sos = resp.getOutputStream(); 
        ImageIO.write(rdnu.getBuffImg(), "jpeg", sos); 
        sos.close(); 
    }
}
最近下载更多
sunlea  LV20 2024年5月23日
爱丽淇  LV5 2024年3月18日
杨豫川  LV12 2023年5月31日
qq1061521319  LV4 2022年9月15日
wangyang520  LV6 2022年5月2日
crofsun  LV8 2022年3月28日
543666826  LV34 2021年11月19日
cyrus6693  LV2 2021年10月25日
lironggang  LV38 2021年8月31日
小安同学  LV7 2021年6月20日
最近浏览更多
Solowen 4月16日
暂无贡献等级
cq1458824624 1月14日
暂无贡献等级
张春青  LV6 2024年11月14日
123456cjj  LV1 2024年6月2日
sunlea  LV20 2024年5月22日
李俊雄  LV3 2024年4月30日
FFF112233  LV8 2024年3月27日
爱丽淇  LV5 2024年3月18日
qq3577025766  LV6 2024年3月8日
阿凡达  LV9 2024年1月29日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友