使用myecplise 10编译jsp脚本语言,使用mysql数据库和JavaBean完成的一个简单的火车订票系统,实现了买票,改签,退票,用户信息修改,适合于初学者或者小白。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-11-30 17:16 new3
文件 529 2019-11-30 17:16 new3.classpath
目录 0 2019-11-30 17:16 new3.myeclipse
文件 285 2019-11-30 17:16 new3.mymetadata
文件 1747 2019-11-30 17:17 new3.project
目录 0 2019-11-30 17:17 new3.settings
文件 500 2019-11-30 17:16 new3.settings.jsdtscope
文件 589 2019-12-01 13:56 new3.settingsorg.eclipse.core.resources.prefs
文件 395 2019-11-30 17:16 new3.settingsorg.eclipse.jdt.core.prefs
文件 450 2019-11-30 17:16 new3.settingsorg.eclipse.wst.common.component
文件 252 2019-11-30 17:16 new3.settingsorg.eclipse.wst.common.project.facet.core.xml
文件 49 2019-11-30 17:16 new3.settingsorg.eclipse.wst.jsdt.ui.superType.container
文件 6 2019-11-30 17:16 new3.settingsorg.eclipse.wst.jsdt.ui.superType.name
目录 0 2019-12-04 20:26 new3src
目录 0 2019-12-04 22:23 new3srcBean
文件 2494 2019-12-04 22:23 new3srcBeanImage.java
文件 701 2019-12-04 20:39 new3srcBeansql.java
目录 0 2019-12-04 22:43 new3WebRoot
文件 1358 2019-12-04 19:57 new3WebRootuyinfo.jsp
文件 3299 2019-12-05 09:36 new3WebRootBuyTickets.jsp
文件 2967 2019-12-05 09:37 new3WebRootBuyTicketsThen.jsp
文件 2594 2019-12-05 09:39 new3WebRootchangePassword.jsp
文件 2306 2019-12-05 09:41 new3WebRootChangeSave.jsp
文件 286 2019-12-04 22:27 new3WebRootchenk.jsp
文件 2459 2019-12-04 22:41 new3WebRootdoLogin.jsp
文件 3447 2019-12-05 09:46 new3WebRootgaiqian.jsp
文件 3059 2019-12-05 09:56 new3WebRootgaiqiansuccess.jsp
目录 0 2019-12-04 21:22 new3WebRootimage
文件 329 2019-12-04 22:25 new3WebRootimage.jsp
文件 587699 2019-12-04 19:48 new3WebRootimage1.jpg
文件 834 2019-11-30 17:16 new3WebRootindex.jsp
............此处省略21个文件信息
package Bean;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Random;
import javax.imageio.ImageIO;
public class Image {
// 验证码图片中可以出现的字符集,可根据需要修改
private char mapTable[] = { ‘a‘ ‘b‘ ‘c‘ ‘d‘ ‘e‘ ‘f‘ ‘g‘ ‘h‘ ‘i‘
‘j‘ ‘k‘ ‘l‘ ‘m‘ ‘n‘ ‘o‘ ‘p‘ ‘q‘ ‘r‘ ‘s‘ ‘t‘ ‘u‘ ‘v‘
‘w‘ ‘x‘ ‘y‘ ‘z‘ ‘0‘ ‘1‘ ‘2‘ ‘3‘ ‘4‘ ‘5‘ ‘6‘ ‘7‘ ‘8‘
‘9‘ };
/**
* 功能:生成彩色验证码图片 参数width为生成图片的宽度,参数height为生成图片的高度,参数os为页面的输出流
*/
public String getCertPic(int width int height OutputStream os) {
if (width <= 0)
width = 60;
if (height <= 0)
height = 20;
BufferedImage image = new BufferedImage(width height
BufferedImage.TYPE_INT_RGB);
// 获取图形上下文
Graphics g = image.getGraphics();
// 设定背景色
g.setColor(new Color(0xDCDCDC));
g.fillRect(0 0 width height);
// 画边框
g.setColor(Color.BLACK);
g.drawRect(0 0 width - 1 height - 1);
// 取随机产生的认证码
String strEnsure = ““;
for (int i = 0; i < 4; ++i) {
strEnsure += mapTable[(int) (mapTable.length * Math.random())];
}
// 将认证码显示到图像中,如果要生成更多位的验证码,增加drawString语句
g.setColor(Color.BLACK);
g.setFont(new Font(“Atlantic Inline“ Font.PLAIN 18));
String str = strEnsure.substring(0 1);
g.drawString(str 8 17);
str = strEnsure.substring(1 2);
g.drawString(str 20 15);
str = strEnsure.substring(2 3);
g.drawString(str 35 18);
str = strEnsure.substring(3 4);
g.drawString(str 45 15);
// 随机产生10个干扰点
Random rand = new Random();
for (int i = 0; i < 10; i++) {
int x = rand.nextInt(width);
int y = rand.nextInt(height);
g.drawOval(x y 1 1);
}
// 释放图形上下文
g.dispose();
try {
// 输出图像到页面
ImageIO.write(image “JPEG“ os);
} catch (IOException e) {
System.out.println(e.getMessage());
return ““;
}
return strEnsure;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-11-30 17:16 new3
文件 529 2019-11-30 17:16 new3.classpath
目录 0 2019-11-30 17:16 new3.myeclipse
文件 285 2019-11-30 17:16 new3.myme
文件 1747 2019-11-30 17:17 new3.project
目录 0 2019-11-30 17:17 new3.settings
文件 500 2019-11-30 17:16 new3.settings.jsdtscope
文件 589 2019-12-01 13:56 new3.settingsorg.eclipse.core.resources.prefs
文件 395 2019-11-30 17:16 new3.settingsorg.eclipse.jdt.core.prefs
文件 450 2019-11-30 17:16 new3.settingsorg.eclipse.wst.common.component
文件 252 2019-11-30 17:16 new3.settingsorg.eclipse.wst.common.project.facet.core.xm
文件 49 2019-11-30 17:16 new3.settingsorg.eclipse.wst.jsdt.ui.superType.container
文件 6 2019-11-30 17:16 new3.settingsorg.eclipse.wst.jsdt.ui.superType.name
目录 0 2019-12-04 20:26 new3src
目录 0 2019-12-04 22:23 new3srcBean
文件 2494 2019-12-04 22:23 new3srcBeanImage.java
文件 701 2019-12-04 20:39 new3srcBeansql.java
目录 0 2019-12-04 22:43 new3WebRoot
文件 1358 2019-12-04 19:57 new3WebRootuyinfo.jsp
文件 3299 2019-12-05 09:36 new3WebRootBuyTickets.jsp
文件 2967 2019-12-05 09:37 new3WebRootBuyTicketsThen.jsp
文件 2594 2019-12-05 09:39 new3WebRootchangePassword.jsp
文件 2306 2019-12-05 09:41 new3WebRootChangeSave.jsp
文件 286 2019-12-04 22:27 new3WebRootchenk.jsp
文件 2459 2019-12-04 22:41 new3WebRootdoLogin.jsp
文件 3447 2019-12-05 09:46 new3WebRootgaiqian.jsp
文件 3059 2019-12-05 09:56 new3WebRootgaiqiansuccess.jsp
目录 0 2019-12-04 21:22 new3WebRootimage
文件 329 2019-12-04 22:25 new3WebRootimage.jsp
文件 587699 2019-12-04 19:48 new3WebRootimage1.jpg
文件 834 2019-11-30 17:16 new3WebRootindex.jsp
............此处省略21个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)