生成验证码(JSP)——简易方法

上代码

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>生成验证码</title>
</head>
<body>
<hr color="blue"></hr>
请输入账号:<input name="userid" maxlength="20"/><br/>

请输入密码:<input name="password" type="password" maxlength="20"/><br/>

<form action="" method="post" name="formName">
      请选择角色:<input type="radio" name="role" value="teacher" checked="checked">教师   
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       <input type="radio" name="role" value="student">学生
</form>
请输入账号:<input name="userid" maxlength="20"/>
验证码:
<%   //'A~Z' 65-90
    //'0~9'  48-57
    char[] c = {'0','1','2','3','4','5','6','7','8','9','Q','W','E','R','T','Y','U','I','O','P','A','S','D','F','G','H','J','K','L','Z','X','C','V','B','N','M'};
    int n;
    for(int i=0;i<4;i++){
        n  = (int)(Math.random()*36);
%>
<%=c[n] %>
<%
    }

%>
<br/>
<button name="reset" value="重置">重置</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button name="submit" valur="登录">登录</button>

<hr color="blue"></hr>
</body>
</html>

效果如图
生成验证码(JSP)——简易方法

上一篇:数据库备份工具Xtrabackup


下一篇:【C++】VSCode配置C++环境(详细教程)