package Servlet;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class register
*/
@WebServlet("/register")
public class register extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public register() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String name = request.getParameter("username");
String pass = request.getParameter("password");
String compass = request.getParameter("compass");
String phone = request.getParameter("phone");
String phone_reg = "0?(13|14|15|18|17)[0-9]{9}";
Pattern r = Pattern.compile(phone_reg);
Matcher m = r.matcher(phone);
if(!pass.equals(compass)) {//两次密码正确
response.sendRedirect("jsp/register.jsp");
}else if(!m.matches()) {//手机号11位匹配
request.getRequestDispatcher("jsp/register.jsp").forward(request, response);
}else {
request.getSession().setAttribute("name", name);
request.getSession().setAttribute("pass", pass);
response.sendRedirect("jsp/login.jsp");
}
}
}
![avatar](https://profile-avatar.csdnimg.cn/89f260110edf4c8dad697d5f0224570b_weixin_73848274.jpg!1)
竹南Track
- 粉丝: 0
- 资源: 2
最新资源
- 8051Proteus仿真c源码用if语句控制P0口8位LED的流水方向
- C++打字游戏(练打字的)(带声音)
- 8051Proteus仿真c源码用for语句控制蜂鸣器鸣笛次数
- 数字电子技术实验报告+
- 8051Proteus仿真c源码用do-while语句控制P0口8位LED流水点亮
- 8051Proteus仿真c源码用DAC0832产生锯齿波电压
- 1锁相环 PLL 几个版本的matlab相位噪声拟合仿真代码,质量杠杠的,都是好东西 2锁相环matlab建模稳定性仿
- 2024年CIMC离散行业自动化(逻辑算法)初赛 - 样题
- 8051Proteus仿真c源码用89C51做稳压直流稳压电源
- 使用yolov7对思源公司的目标检测项目 .zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)