📄 authcode.jsp
字号:
<%@ page contentType="image/jpeg" import="java.awt.*,java.awt.image.*,java.util.*,javax.imageio.*" %>
<%
String authcode = (String)session.getAttribute("authcode");
int width=40, height=20;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, width, height);
g.setColor(Color.black);
g.drawRect(0,0,width-1,height-1);
String rand = authcode;
g.setColor(Color.black);
g.setFont(new Font("Times New Roman",Font.BOLD,15));
g.drawString(rand,3,15);
Random random = new Random();
for (int i=0;i<40;i++)
{
int x = random.nextInt(width);
int y = random.nextInt(height);
g.drawLine(x,y,x,y);
}
g.dispose();
ImageIO.write(image, "JPEG", response.getOutputStream());
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -