慕娘5532926
2018-08-16 09:27
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
Users users = new Users();
String username,mypassword,gender,email,introduce,isAccept;
Date birthday;
String[] favorites;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
username = request.getParameter("username");
mypassword = request.getParameter("mypassword");
gender = request.getParameter("gender");
email = request.getParameter("email");
introduce = request.getParameter("introduce");
birthday = sdf.parse(request.getParameter("birthday"));
if(request.getParameterValues("isAccept") != null){
isAccept = request.getParameter("isAccept");
}else{
isAccept = "false";
}
favorites = request.getParameterValues("favorite");
users.setUsername(username);
users.setMypassword(mypassword);
users.setGender(gender);;
users.setEmail(email);;
users.setFavorites(favorites);
users.setIntroduce(introduce);
users.setBirthday(birthday);
if(isAccept.equals("true")){
users.setFlag(true);
}else{
users.setFlag(false);
}
//把注册成功的用户对象保存到session中
request.getSession().setAttribute("regUser", users);
request.getRequestDispatcher("../userinfo.jsp").forward(request, response);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
老师这个Accept拼错了
我也是呀 什么情况
你导入java.util.Date这个包了吗?
JAVA遇见HTML——Servlet篇
160615 学习 · 1029 问题
相似问题