• 大小: 99.29M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2022-11-24
  • 语言: 其他
  • 标签: 其他  

资源简介

zshop.rar

资源截图

代码片段和文件信息

package com.itany.zshop.backend.controller;

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

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * Author:汤小洋
 * Date:2018-04-28 15:18
 * Description:<描述>
 */
@Controller
@RequestMapping(“/backend/code“)
public class CodeController {

    @RequestMapping(“/image“)
    public void image(HttpServletRequest request HttpServletResponse response) throws IOException {
        request.setCharacterEncoding(“utf-8“);

        BufferedImage bfi = new BufferedImage(80 25 BufferedImage.TYPE_INT_RGB);
        Graphics g = bfi.getGraphics();
        g.fillRect(0 0 80 25);

        //验证码字符范围
        char[] ch = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789“.toCharArray();
        Random r = new Random();
        int index;
        StringBuffer sb = new StringBuffer(); //保存字符串
        for (int i = 0; i < 4; i++) {
            index = r.nextInt(ch.length);
            g.setColor(new Color(r.nextInt(255) r.nextInt(255) r.nextInt(255)));
            Font font = new Font(“宋体“ 30 20);
            g.setFont(font);
            g.drawString(ch[index] + ““ (i * 20) + 2 23);
            sb.append(ch[index]);
        }

        // 添加噪点
        int area = (int) (0.02 * 60 * 25);
        for (int i = 0; i < area; ++i) {
            int x = (int) (Math.random() * 80);
            int y = (int) (Math.random() * 25);
            bfi.setRGB(x y (int) (Math.random() * 255));
        }

        //设置验证码中的干扰线
        for (int i = 0; i < 3; i++) {
            //随机获取干扰线的起点和终点
            int xstart = (int) (Math.random() * 80);
            int ystart = (int) (Math.random() * 25);
            int xend = (int) (Math.random() * 80);
            int yend = (int) (Math.random() * 25);
            g.setColor(interLine(1 255));
            g.drawLine(xstart ystart xend yend);
        }
        HttpSession session = request.getSession();  //保存到session
        session.setAttribute(“verificationCode“ sb.toString());
        ImageIO.write(bfi “JPG“ response.getOutputStream());  //写到输出流
    }

    private static Color interLine(int Low int High) {
        if (Low > 255)
            Low = 255;
        if (High > 255)
            High = 255;
        if (Low < 0)
            Low = 0;
        if (High < 0)
            High = 0;
        int interval = High - Low;
        int r = Low + (int) (Math.random() * interval);
        int g = Low + (int) (Math.random() * interval);
        int b = Low + (int) (Math.random() * interval);
        retu

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件          5  2018-04-26 09:24  zshop\zshop_code\zshop\.idea\.name

     文件        361  2018-04-26 09:42  zshop\zshop_code\zshop\.idea\artifacts\zshop_backend_web_war.xml

     文件       4596  2018-05-15 17:19  zshop\zshop_code\zshop\.idea\artifacts\zshop_backend_web_war_exploded.xml

     文件        353  2018-04-26 09:43  zshop\zshop_code\zshop\.idea\artifacts\zshop_front_web_war.xml

     文件       4582  2018-05-15 17:19  zshop\zshop_code\zshop\.idea\artifacts\zshop_front_web_war_exploded.xml

     文件       1703  2018-04-26 09:38  zshop\zshop_code\zshop\.idea\compiler.xml

     文件         76  2018-04-26 09:24  zshop\zshop_code\zshop\.idea\copyright\profiles_settings.xml

     文件       7356  2018-04-28 09:27  zshop\zshop_code\zshop\.idea\dataSources.ids

     文件        422  2018-04-26 11:42  zshop\zshop_code\zshop\.idea\dataSources.local.xml

     文件        981  2018-04-26 11:42  zshop\zshop_code\zshop\.idea\dataSources.xml

     文件       2162  2018-05-15 16:25  zshop\zshop_code\zshop\.idea\encodings.xml

     文件        594  2018-05-09 14:53  zshop\zshop_code\zshop\.idea\libraries\Maven__commons_beanutils_commons_beanutils_1_9_3.xml

     文件        536  2018-05-15 16:25  zshop\zshop_code\zshop\.idea\libraries\Maven__commons_codec_commons_codec_1_9.xml

     文件        616  2018-05-09 14:53  zshop\zshop_code\zshop\.idea\libraries\Maven__commons_collections_commons_collections_3_2_2.xml

     文件        605  2018-04-26 09:55  zshop\zshop_code\zshop\.idea\libraries\Maven__commons_fileupload_commons_fileupload_1_3_1.xml

     文件        503  2018-04-26 09:55  zshop\zshop_code\zshop\.idea\libraries\Maven__commons_io_commons_io_2_2.xml

     文件        558  2018-04-26 09:54  zshop\zshop_code\zshop\.idea\libraries\Maven__commons_logging_commons_logging_1_2.xml

     文件        514  2018-05-09 15:06  zshop\zshop_code\zshop\.idea\libraries\Maven__commons_net_commons_net_3_1.xml

     文件        486  2018-04-26 09:53  zshop\zshop_code\zshop\.idea\libraries\Maven__com_alibaba_druid_1_1_6.xml

     文件        514  2018-04-26 09:55  zshop\zshop_code\zshop\.idea\libraries\Maven__com_alibaba_fastjson_1_2_47.xml

     文件        547  2018-04-26 09:54  zshop\zshop_code\zshop\.idea\libraries\Maven__com_github_jsqlparser_jsqlparser_1_0.xml

     文件        561  2018-04-26 09:54  zshop\zshop_code\zshop\.idea\libraries\Maven__com_github_pagehelper_pagehelper_5_1_2.xml

     文件        578  2018-04-26 09:57  zshop\zshop_code\zshop\.idea\libraries\Maven__javax_servlet_javax_servlet_api_3_1_0.xml

     文件        510  2018-04-26 09:57  zshop\zshop_code\zshop\.idea\libraries\Maven__javax_servlet_jsp_jsp_api_2_2.xml

     文件        437  2018-05-09 14:34  zshop\zshop_code\zshop\.idea\libraries\Maven__jstl_jstl_1_2.xml

     文件        455  2018-04-26 09:32  zshop\zshop_code\zshop\.idea\libraries\Maven__junit_junit_4_11.xml

     文件        574  2018-04-26 09:53  zshop\zshop_code\zshop\.idea\libraries\Maven__mysql_mysql_connector_java_5_1_38.xml

     文件        570  2018-05-15 17:19  zshop\zshop_code\zshop\.idea\libraries\Maven__org_apache_commons_commons_pool2_2_4_2.xml

     文件        577  2018-05-15 16:25  zshop\zshop_code\zshop\.idea\libraries\Maven__org_apache_httpcomponents_httpclient_4_5_2.xml

     文件        563  2018-05-15 16:25  zshop\zshop_code\zshop\.idea\libraries\Maven__org_apache_httpcomponents_httpcore_4_4_4.xml

............此处省略1177个文件信息

评论

共有 条评论