package com.neuedu.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.neuedu.pojo.User;
import com.neuedu.service.IUserService;
import com.neuedu.service.ipml.UserServiceImpl;
/**
* Servlet implementation class regservlet
*/
@WebServlet("/regservlet")
public class regservlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public regservlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String name = request.getParameter("name");
String password = request.getParameter("password");
String repeatpwd = request.getParameter("repeatpwd");
String email = request.getParameter("email");
String idcard = request.getParameter("idcard");
IUserService userservice = new UserServiceImpl();
User j = userservice.checkuser(name);
if (j == null) {
User user = new User();
user.setName(name);
user.setPassword(password);
user.setRepeatpwd(repeatpwd);
user.setEmail(email);
user.setIdcard(idcard);
int i = userservice.adduser(user);
String result;
if (i > 0) {
response.getWriter().print("成功<a href='login.jsp'>登录</a>");
} else {
request.setAttribute("result", "注册失败");
}
} else {
response.getWriter().print("用户名已存在<a href='reg.jsp'>注册</a>");
}
}
}
regservlet
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 你有过去追求安全感而不敢去做某些事情吗?比如说因为恐而让你不敢登山。你有过因为这些自己或者他人赋予的外在标签,而让...