资源简介
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.xm
文件 4596 2018-05-15 17:19 zshop\zshop_code\zshop\.idea\artifacts\zshop_backend_web_war_exploded.xm
文件 353 2018-04-26 09:43 zshop\zshop_code\zshop\.idea\artifacts\zshop_front_web_war.xm
文件 4582 2018-05-15 17:19 zshop\zshop_code\zshop\.idea\artifacts\zshop_front_web_war_exploded.xm
文件 1703 2018-04-26 09:38 zshop\zshop_code\zshop\.idea\compiler.xm
文件 76 2018-04-26 09:24 zshop\zshop_code\zshop\.idea\copyright\profiles_settings.xm
文件 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.xm
文件 981 2018-04-26 11:42 zshop\zshop_code\zshop\.idea\dataSources.xm
文件 2162 2018-05-15 16:25 zshop\zshop_code\zshop\.idea\encodings.xm
文件 594 2018-05-09 14:53 zshop\zshop_code\zshop\.idea\libraries\Maven__commons_beanutils_commons_beanutils_1_9_3.xm
文件 536 2018-05-15 16:25 zshop\zshop_code\zshop\.idea\libraries\Maven__commons_codec_commons_codec_1_9.xm
文件 616 2018-05-09 14:53 zshop\zshop_code\zshop\.idea\libraries\Maven__commons_collections_commons_collections_3_2_2.xm
文件 605 2018-04-26 09:55 zshop\zshop_code\zshop\.idea\libraries\Maven__commons_fileupload_commons_fileupload_1_3_1.xm
文件 503 2018-04-26 09:55 zshop\zshop_code\zshop\.idea\libraries\Maven__commons_io_commons_io_2_2.xm
文件 558 2018-04-26 09:54 zshop\zshop_code\zshop\.idea\libraries\Maven__commons_logging_commons_logging_1_2.xm
文件 514 2018-05-09 15:06 zshop\zshop_code\zshop\.idea\libraries\Maven__commons_net_commons_net_3_1.xm
文件 486 2018-04-26 09:53 zshop\zshop_code\zshop\.idea\libraries\Maven__com_alibaba_druid_1_1_6.xm
文件 514 2018-04-26 09:55 zshop\zshop_code\zshop\.idea\libraries\Maven__com_alibaba_fastjson_1_2_47.xm
文件 547 2018-04-26 09:54 zshop\zshop_code\zshop\.idea\libraries\Maven__com_github_jsqlparser_jsqlparser_1_0.xm
文件 561 2018-04-26 09:54 zshop\zshop_code\zshop\.idea\libraries\Maven__com_github_pagehelper_pagehelper_5_1_2.xm
文件 578 2018-04-26 09:57 zshop\zshop_code\zshop\.idea\libraries\Maven__javax_servlet_javax_servlet_api_3_1_0.xm
文件 510 2018-04-26 09:57 zshop\zshop_code\zshop\.idea\libraries\Maven__javax_servlet_jsp_jsp_api_2_2.xm
文件 437 2018-05-09 14:34 zshop\zshop_code\zshop\.idea\libraries\Maven__jstl_jstl_1_2.xm
文件 455 2018-04-26 09:32 zshop\zshop_code\zshop\.idea\libraries\Maven__junit_junit_4_11.xm
文件 574 2018-04-26 09:53 zshop\zshop_code\zshop\.idea\libraries\Maven__mysql_mysql_connector_java_5_1_38.xm
文件 570 2018-05-15 17:19 zshop\zshop_code\zshop\.idea\libraries\Maven__org_apache_commons_commons_pool2_2_4_2.xm
文件 577 2018-05-15 16:25 zshop\zshop_code\zshop\.idea\libraries\Maven__org_apache_httpcomponents_httpclient_4_5_2.xm
文件 563 2018-05-15 16:25 zshop\zshop_code\zshop\.idea\libraries\Maven__org_apache_httpcomponents_httpcore_4_4_4.xm
............此处省略1177个文件信息
相关资源
- 自动机理论、语言和计算导论(原书
- 视频翻录-wuzuowei.net.7z
- 毛星云OpenCV3编程入门和配套源码.zi
- 以太坊技术详解与实战.rar
- DavidM.KroenkeDavidJ.AuerScottL.VandenbergRobe
- AstronomyToday8thEdition.part1.rar
- zw_无线通信_美Andrea+Gold_11842473.zip
- 9787302446156玩转Office轻松过二级(第
- Primerc第5版.zip
- sgcWebSockets421.zip
- 《ArcGISEngineC入门经典》程序代码.ra
- 1714612Win7-USB3.0-Creator-V3-Win7Admin.zip
- 米花同城6.6.9全开源解密还有小程序代
- zw_BDA_1_1_1.zip
- 离散时间信号处理第3版__美奥本海姆
- ANSYSICEMCFD从入门到精通.pdf
- 人人商城介绍PPT.pdf
- a4bb48258dd4c727334e7a3a5838f20c.exe
- 基于FPAG的混沌系统实现.zip
- 普林斯顿微积分读本670页清晰+微积分
- FPGA数字逻辑设计教程--Verilog.pdf
- pdf(10)
- 程序员的数学.zip
- XToolsPro17.0FullVersion.rar
- 周志华机器学习全书16章ppt.zip
- 《微信小程序开发入门与实践.雷磊》
- zw_Qt一去丶二三里Blog二.zip
- JamesW.NilssonSusanA.Riedel-ElectricCircuits11
- scratch2.0二次开发.rar
- AWD工具.zip
评论
共有 条评论