概述
package com.wh.action;
import java.io.IOException;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.wh.entity.User;
import com.wh.servie.RegisterServie;
import com.wh.servie.RegisterServieIml;
import com.wh.utils.DateUtil;
@SuppressWarnings("serial")
public class RegisterServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
// TODO Auto-generated method stub
String function = request.getParameter("function");
if ("register".equals(function)) {
this.register(request, response);
}else if("reRegister".equals(function)) {
this.reRegister(request,response);
}
}
private void reRegister(HttpServletRequest request, HttpServletResponse response) throws IOException {
// TODO Auto-generated method stub
response.sendRedirect("/loginProject/register.jsp");
}
@SuppressWarnings("rawtypes")
private void register(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
String username = request.getParameter("username");
String password = request.getParameter("password");
String name = request.getParameter("name");
String gender = request.getParameter("gender");
int age = Integer.parseInt(request.getParameter("age"));
String address = request.getParameter("address");
Date regdate = DateUtil.dateParse(request.getParameter("regdate"), "yyyy-MM-dd ");
@SuppressWarnings("unused")
User user = new User(username, password, name, gender, age, address, regdate);
// 掉用service层
RegisterServie registerServie = new RegisterServieIml();
Enum registerStatu = registerServie.register(user);
request.setAttribute("rs", registerStatu);
request.getRequestDispatcher("/registerStatu.jsp").forward(request, response);
}
}
最后
以上就是鳗鱼电灯胆为你收集整理的注册的action层的全部内容,希望文章能够帮你解决注册的action层所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复