2020-11-05韩德云

学习总结:
1、设置字符编码
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
2、获取表单数据
String username = request.getParameter("username");
String password = request.getParameter("password");
String gender = request.getParameter("gender");
4、调用数据库的添加方法
DBUtils dbutils = new DBUtils();
int i =dbutils.save(username,password,gender);
5、处理结果
if(i > 0) {
request.getSession().setAttribute("msg", "注册成功");
response.sendRedirect("register.jsp");
}else{
request.getSession().setAttribute("msg", "注册失败");
response.sendRedirect("register.jsp");

注册页面
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8")
String username = request.getParameter("username");
String password = request.getParameter("password");
String gender = request.getParameter("gender");
DBHelper dbhelper = new DBHelper();
int i =dbhelper.save(username,password,gender);
if(i > 0) {
request.getSession().setAttribute("msg","注册成功");
response.sendRedirect("denglu.jsp");
}else{
request.getSession().setAttribute("msg","注册失败");
response.sendRedirect("denglu.jsp");
}

心得体会:今天学习状态太差了,啥都不是,白搭了刚开始那么好的开头,没能坚持到最后关头。气死人,再来呗,没啥大不了的,再来。

标签

评论

© 2021 成都云创动力科技有限公司 蜀ICP备20006351号-1