AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
[TOC] # 用户注册实例 **代码片段:** reg.jsp ~~~ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <form action="regService.jsp" method="post"> 用户名:<input type="text" name="username" value=""/><br/> 密码:<input type="password" name="password" value=""/><br/> <input type="submit" value="注册" /> </form> </body> </html> ~~~ regService.jsp ~~~ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% String username = request.getParameter("username"); String password = request.getParameter("password"); boolean usernameCheck = null != username && username.trim().length() > 6; boolean passwordCheck = null != password && password.trim().length() > 6; if (usernameCheck && passwordCheck) { // 往数据库插入数据 %> <jsp:forward page="regSuccess.jsp"></jsp:forward> <% } else { %> <jsp:forward page="regError.jsp"></jsp:forward> <% } %> </body> </html> ~~~ regSuccess.jsp ~~~ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <h1>恭喜你,注册成功!</h1> <!-- 把所有的注册用户信息全部都显示出来 --> </body> </html> ~~~ regError.jsp ~~~ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <h1>用户名或者密码不符合要求,<a href="reg.jsp">点击重新注册</a></h1> </body> </html> ~~~