資源簡介
超市庫存管理系統,java開發,ssm框架mySQL數據庫,完美運行,可做畢設可商用
代碼片段和文件信息
package?com.supermarket.controller;
import?java.awt.Color;
import?java.awt.Font;
import?java.awt.Graphics;
import?java.awt.Graphics2D;
import?java.awt.image.BufferedImage;
import?java.util.Random;
import?javax.imageio.ImageIO;
import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpServletResponse;
import?org.springframework.stereotype.Controller;
import?org.springframework.web.bind.annotation.RequestMapping;
/**
?*?驗證碼生成器
?*?@author?13713
?*
?*/
@Controller
public?class?DrawImageController?{
public?static?final?int?WIDTH?=?120;
public?static?final?int?HEIGHT?=?30;
?/**
?????*?生成圖片
?????*?@param?request
?????*?@param?response
?????*/
????@RequestMapping(“/drawImage“)
????public?void?drawImage(HttpServletRequest?request?HttpServletResponse?response)throws?Exception{
???? request.setCharacterEncoding(“utf-8“);
response.setContentType(“text/html;charset=utf-8“);
//?創建緩存
BufferedImage?bi?=?new?BufferedImage(WIDTH?HEIGHT
BufferedImage.TYPE_INT_RGB);
//?獲得畫布
Graphics?g?=?bi.getGraphics();
//?設置背影色
setBackGround(g);
//?設置邊框
setBorder(g);
//?畫干擾線
drawRandomLine(g);
//?寫隨機數
String?random?=?drawRandomNum((Graphics2D)?g);
//?將隨機漢字存在session中
request.getSession().setAttribute(“checkcode“?random);
//?將圖形寫給瀏覽器
response.setContentType(“image/jpeg“);
//?發頭控制瀏覽器不要緩存
response.setDateHeader(“expries“?-1);
response.setHeader(“Cache-Control“?“no-cache“);
response.setHeader(“Pragma“?“no-cache“);
//?將圖片寫給瀏覽器
ImageIO.write(bi?“jpg“?response.getOutputStream());
????}
????
????/**
?*?設置背景色
?*?
?*?@param?g
?*/
private?void?setBackGround(Graphics?g)?{
//?設置顏色
g.setColor(new?Color(22?160?133));
//?填充區域
g.fillRect(0?0?WIDTH?HEIGHT);
}
/**
?*?設置邊框
?*?
?*?@param?g
?*/
private?void?setBorder(Graphics?g)?{
//?設置邊框顏色
g.setColor(new?Color(22?160?133));
//?邊框區域
g.drawRect(1?1?WIDTH?-?2?HEIGHT?-?2);
}
/**
?*?畫隨機線條
?*?
?*?@param?g
?*/
private?void?drawRandomLine(Graphics?g)?{
//?設置顏色
g.setColor(Color.WHITE);
//?設置線條個數并畫線
for?(int?i?=?0;?i?5;?i++)?{
int?x1?=?new?Random().nextInt(WIDTH);
int?y1?=?new?Random().nextInt(HEIGHT);
int?x2?=?new?Random().nextInt(WIDTH);
int?y2?=?new?Random().nextInt(HEIGHT);
g.drawLine(x1?y1?x2?y2);
}
}
/**
?*?畫隨機漢字
?*?
?*?@param?g
?*?@return
?*/
private?String?drawRandomNum(Graphics2D?g)?{
StringBuffer?sb?=?new?StringBuffer();
//?設置顏色
g.setColor(Color.WHITE);
//?設置字體
g.setFont(new?Font(“宋體“?Font.BOLD?20));
//?準備常用漢字集
String?base?=?“\u7684\u4e00\u4e86\u662f\u6211\u4e0d\u5728\u4eba\u4eec\u6709\u6765\u4ed6\u8fd9\u4e0a\u7740\u4e2a\u5730\u5230\u5927\u91cc\u8bf4\u5c31\u53bb\u5b50\u5f97\u4e5f\u548c\u90a3\u8981\u4e0b\u770b\u5929\u65f6\u8fc7\u51fa\u5c0f\u4e48\u8d77\u4f60\u90fd\u628a\u597d\u8fd8\u591a\u6ca1\u4e3a\u53c8\u53ef\u5bb6\u5b66\u53ea\u4ee5\u4e3b\u4f1a\u683
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????13941??2018-07-11?21:15??超市管理系統\db_supermarketmanager.sql
?????文件???????1272??2018-05-28?11:02??超市管理系統\SupermarketManager\.classpath
?????文件???????1227??2018-05-27?17:18??超市管理系統\SupermarketManager\.project
?????文件????????639??2018-05-27?17:18??超市管理系統\SupermarketManager\.settings\.jsdtscope
?????文件????????157??2018-07-04?16:07??超市管理系統\SupermarketManager\.settings\org.eclipse.core.resources.prefs
?????文件????????430??2018-05-27?17:18??超市管理系統\SupermarketManager\.settings\org.eclipse.jdt.core.prefs
?????文件?????????90??2018-05-27?17:18??超市管理系統\SupermarketManager\.settings\org.eclipse.m2e.core.prefs
?????文件????????779??2018-05-28?11:02??超市管理系統\SupermarketManager\.settings\org.eclipse.wst.common.component
?????文件????????252??2018-05-27?17:18??超市管理系統\SupermarketManager\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件?????????49??2018-05-27?17:18??超市管理系統\SupermarketManager\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2018-05-27?17:18??超市管理系統\SupermarketManager\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件?????????50??2018-05-27?17:18??超市管理系統\SupermarketManager\.settings\org.eclipse.wst.validation.prefs
?????文件???????5989??2018-05-28?09:26??超市管理系統\SupermarketManager\pom.xm
?????文件???????6216??2018-05-28?14:34??超市管理系統\SupermarketManager\src\main\java\com\supermarket\controller\DrawImageController.java
?????文件???????5098??2018-07-10?12:46??超市管理系統\SupermarketManager\src\main\java\com\supermarket\controller\GoodsController.java
?????文件???????5541??2018-07-05?00:41??超市管理系統\SupermarketManager\src\main\java\com\supermarket\controller\GoodsTypeController.java
?????文件???????3551??2018-06-22?14:34??超市管理系統\SupermarketManager\src\main\java\com\supermarket\controller\MenuController.java
?????文件???????2514??2018-07-10?12:56??超市管理系統\SupermarketManager\src\main\java\com\supermarket\controller\OrderController.java
?????文件???????3078??2018-07-05?17:52??超市管理系統\SupermarketManager\src\main\java\com\supermarket\controller\RoleController.java
?????文件???????2781??2018-07-02?22:52??超市管理系統\SupermarketManager\src\main\java\com\supermarket\controller\SupplierController.java
?????文件???????5789??2018-07-10?13:00??超市管理系統\SupermarketManager\src\main\java\com\supermarket\controller\UserController.java
?????文件????????542??2018-07-05?03:44??超市管理系統\SupermarketManager\src\main\java\com\supermarket\dao\GoodsDao.java
?????文件????????603??2018-07-02?20:22??超市管理系統\SupermarketManager\src\main\java\com\supermarket\dao\GoodsTypeDao.java
?????文件????????306??2018-06-22?14:46??超市管理系統\SupermarketManager\src\main\java\com\supermarket\dao\MenuDao.java
?????文件????????335??2018-07-04?17:43??超市管理系統\SupermarketManager\src\main\java\com\supermarket\dao\OrderDao.java
?????文件????????462??2018-06-02?10:09??超市管理系統\SupermarketManager\src\main\java\com\supermarket\dao\RoleDao.java
?????文件????????281??2018-06-22?14:36??超市管理系統\SupermarketManager\src\main\java\com\supermarket\dao\RoleMenuDao.java
?????文件?????????65??2018-07-05?03:08??超市管理系統\SupermarketManager\src\main\java\com\supermarket\dao\SaleDao.java
?????文件????????448??2018-06-24?10:33??超市管理系統\SupermarketManager\src\main\java\com\supermarket\dao\SupplierDao.java
?????文件????????518??2018-06-22?14:45??超市管理系統\SupermarketManager\src\main\java\com\supermarket\dao\UserDao.java
............此處省略769個文件信息
- 上一篇:java游戲保衛蘿卜
- 下一篇:aspose.pdf-17.8.jar
評論
共有 條評論