1、我们来看看后台操作的业务流程

每一层都按照上面的步骤来进行实现:

这里我们要使用commUtils.toBean把表单提交的参数封装成User对象,必须保证User对象中的字段和表单提交的字段的名称是一模一样的

<tr>
<td align="right">新密码:</td>
<td><input class="input" type="password" name="newpass" id="newpass" value=""/></td>
<td><label id="newpassError" class="error"></label></td>
</tr>

这里对应的是newpass,那么User对象的字段也必须是newpass


package com.weiyuan.goods.user.domian;


public class User {


private String uid; //主键
private String loginname;// 登陆名称
private String loginpass;// 登陆密码
private String email;//注册的邮箱
private String verifyCode; //验证码
private int status;//是否激活
private String activationCode;//激活码

//增加下面的几个字段
private String reloginpass; //确认密码
private String newpass;//修改密码对应的新密码

public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getReloginpass() {
return reloginpass;
}
public void setReloginpass(String reloginpass) {
this.reloginpass = reloginpass;
}
public String getNewpass() {
return newpass;
}
public void setNewpass(String newpass) {
this.newpass = newpass;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getLoginname() {
return loginname;
}
public void setLoginname(String loginname) {
this.loginname = loginname;
}
public String getLoginpass() {
return loginpass;
}
public void setLoginpass(String loginpass) {
this.loginpass = loginpass;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getVerifyCode() {
return verifyCode;
}
public void setVerifyCode(String verifyCode) {
this.verifyCode = verifyCode;
}


public String getActivationCode() {
return activationCode;
}
public void setActivationCode(String activationCode) {
this.activationCode = activationCode;
}
@Override
public String toString() {
return "User [uid=" + uid + ", loginname=" + loginname + ", loginpass="
+ loginpass + ", email=" + email + ", verifyCode=" + verifyCode
+ ", status=" + status + ", activationCode=" + activationCode
+ "]";
}


}

 

我们来看看dao层的代码:

package com.weiyuan.goods.user.dao;

import java.sql.SQLException;

import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler; import com.weiyuan.goods.user.domian.User; import cn.itcast.jdbc.TxQueryRunner; public class UserDao { //操作数据库
private TxQueryRunner qr = new TxQueryRunner(); /***
* 查询用户名是否存在
* @throws SQLException
*/
public boolean ajaxValidateLoginName(String loginName) throws SQLException{
//获得满足记录的数目是对象,返回一个整数,整数是单行单列使用ScalarHandler
String sql ="select count(*) from t_user where loginname=?";
Number num = (Number) qr.query(sql, new ScalarHandler(),loginName);
int count = num.intValue(); if(count>0){
return true;
}
return false;
} /***
* 查询邮箱是否存在
* @throws SQLException
*/
public boolean ajaxValidateEmail(String email) throws SQLException{
//获得满足记录的数目是对象,返回一个整数,整数是单行单列使用ScalarHandler
String sql ="select count(*) from t_user where email=?";
Number num = (Number) qr.query(sql, new ScalarHandler(),email);
int count = num.intValue();
System.out.println("count="+count);
if(count>0){
return true;
}
return false;
} /***
* 添加注册的用户
* @throws SQLException
*/
public void addUser(User user) throws SQLException{
//获得满足记录的数目是对象,返回一个整数,整数是单行单列使用ScalarHandler
String sql ="insert into t_user values(?,?,?,?,?,?)";
System.out.println("user="+user.toString());
Object[] params = {user.getUid(),user.getLoginname(),user.getLoginpass(),
user.getEmail(),user.getStatus(),user.getActivationCode()};
qr.update(sql, params);
} /*
* 通过激活码获得用户
* */
public User findUserByActivationCode(String activationCode) throws SQLException{ String sql = "select * from t_user where activationCode = ?";
return qr.query(sql, new BeanHandler<User>(User.class),activationCode);
} /*
* 设置用户的激活状态
* */ public void setUserActivationCode(String uuid,int status) throws SQLException{
String sql = "update t_user set status = ? where uid = ? ";
qr.update(sql,status,uuid);
} /*
* 通过用户名和密码查找得到对应的用户
* */ public User findUserByLoginnameAndPass(String loginName,String pass) throws SQLException{
String sql = "select * from t_user where loginname = ? and loginpass = ?";
return qr.query(sql, new BeanHandler<User>(User.class),loginName,pass);
} /*
* 通过uid和登陆密码查找对应的用户
* **/ public Boolean findUserByUidAndLoginPass(String uid,String loginPass) throws SQLException{ String sql = "select count(*) from t_user where uid = ? and loginpass = ?"; Number num = (Number) qr.query(sql, new ScalarHandler(),uid,loginPass);
if(num.intValue() > 0){
return true;
}else{
return false;
} } /*修改用户的密码*/
public void updateUserPassword(String uid,String newPass) throws SQLException{
String sql = "update t_user set loginpass = ? where uid = ?";
qr.update(sql,newPass,uid); } }

我们来看看业务层的代码:

package com.weiyuan.goods.user.service;

import java.io.IOException;
import java.sql.SQLException;
import java.text.MessageFormat;
import java.util.Properties; import javax.mail.MessagingException;
import javax.mail.Session;
import javax.management.RuntimeErrorException; import cn.itcast.commons.CommonUtils;
import cn.itcast.mail.Mail;
import cn.itcast.mail.MailUtils; import com.weiyuan.goods.user.dao.UserDao;
import com.weiyuan.goods.user.domian.User; public class UserService { private UserDao dao = new UserDao(); public boolean ajaxValidateLoginName(String loginName) { try {
return dao.ajaxValidateLoginName(loginName);
} catch (SQLException e) {
// TODO Auto-generated catch block
throw new RuntimeException(e.getMessage());
} } public boolean ajaxValidateEmail(String email) { try {
return dao.ajaxValidateEmail(email);
} catch (SQLException e) {
// TODO Auto-generated catch block
throw new RuntimeException(e.getMessage());
} } //添加注册的用户
public void addUser(User user){
//添加用户的uuid
user.setUid(CommonUtils.uuid());
//添加用户的激活码
String activationCode = CommonUtils.uuid()+CommonUtils.uuid();
user.setActivationCode(activationCode);
//当前处于未激活的状态
user.setStatus(0);//0表示未激活 try {
dao.addUser(user);
} catch (SQLException e) {
// TODO Auto-generated catch block
throw new RuntimeException(e.getMessage());
} //向注册的用户发送邮件
//1读取配置文件
Properties properties = new Properties();
try {
properties.load(this.getClass().getClassLoader().getResourceAsStream("email_template.properties"));
} catch (IOException e1) {
throw new RuntimeException(e1.getMessage());
} String host = properties.getProperty("host"); //qq邮箱发送邮件的地址,端口465或者587
//qq接受邮件服务器的地址是pop.qq.com,端口995
String username=properties.getProperty("username"); //登陆服务器的账号
String password=properties.getProperty("password");//这里不是客户端登陆的密码,而是授权密码一定要注意
Session session = MailUtils.createSession(host, username, password);
//发送邮件
String from = properties.getProperty("from");//发件人
String to = user.getEmail();//收件人
String title = properties.getProperty("subject");
String content = properties.getProperty("content");
Object [] array = new Object[]{user.getActivationCode()};
//替换占位符
String formatContent = MessageFormat.format(content, user.getActivationCode());//替换占位符
System.out.println("email content is:"+content);
Mail mail = new Mail(from,to,title,formatContent);
try {
MailUtils.send(session, mail);
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
} } /*设置用户的激活状态*/ public void activation(String activationCode) throws Exception{
//1 、通过激活码查找对应的用户信息
try {
User user = dao.findUserByActivationCode(activationCode);
if(user == null){
throw new Exception("无效的激活码");//业务异常,业务失败
}
if(user.getStatus()== 1){
throw new Exception("用户已经既激活,不要二次激活");//业务异常,业务失败
}
dao.setUserActivationCode(user.getUid(), 1); //1表示激活
} catch (SQLException e) {
// TODO Auto-generated catch block
throw new RuntimeException(e.getMessage()); // 不是业务的异常吗,而是电脑环境系统数据库的异常,直接退出线程,无法进行业务的操作了
} } /*
* 用户登录的业务操作,这里传递的参数是一个User对象
* */ public User login(User user){ try {
return dao.findUserByLoginnameAndPass(user.getLoginname(),user.getLoginpass());
} catch (SQLException e) {
throw new RuntimeException(e.getMessage());
} } /*修改用户的密码*/ public void updateUserPassword(String uid ,String oldPass,String newPass) throws Exception{
// 1、查找用户是否存在
try {
Boolean flag = dao.findUserByUidAndLoginPass(uid, oldPass);
if(!flag){
throw new Exception("输入的原始密码有误,请重新输入");
}
// 2、修改用户的密码
dao.updateUserPassword(uid, newPass);
} catch (SQLException e) {
throw new RuntimeException(e.getMessage());
} } }

我们来看看用户控制层Servlet的代码

当用户点击

package com.weiyuan.goods.user.web.servlet;

import java.io.IOException;
import java.net.URLEncoder;
import java.util.Map; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.apache.commons.collections.map.HashedMap; import com.weiyuan.goods.user.domian.User;
import com.weiyuan.goods.user.service.UserService; import cn.itcast.commons.CommonUtils;
import cn.itcast.servlet.BaseServlet; /**
* Servlet implementation class UserServlet
*/
@WebServlet("/UserServlet")
public class UserServlet extends BaseServlet{
private static final long serialVersionUID = 1L;
private UserService service = new UserService();
/*
* 用户注册页面使用ajax校验/*
* 用户注册页面使用ajax校验用户名会调用该方法
* *会调用该方法
* */
public String validateLoginname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
//首先获得用户上传的用户名
String loginName = request.getParameter("loginname");
boolean flag = service.ajaxValidateLoginName(loginName);
response.getWriter().print(flag);
return null;
}
/*
* 用户注册页面使用ajax校验邮箱会调用该方法
* */
public String validateEmail(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
//获得用户上传的emai String email = request.getParameter("email");
System.out.println("validateEmail is called"+email);
boolean flag = service.ajaxValidateEmail(email);
response.getWriter().print(flag);
return null;
} /*
* 用户修改密码页面使用ajax校验原始的密码是否正确
* */
public String validateLoginpass(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
//获得用户上传的emai String loginpass = request.getParameter("loginpass");
boolean flag = service.ajaxValidateLoginPass(loginpass);
response.getWriter().print(flag);
return null;
} /*
* 用户注册页面使用ajax校验验证码会调用该方法
* */
public String validateVerifyCode(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
//获得用户上传的verfycode
String verifyCode = request.getParameter("verifyCode");
//获得session中保存的验证码
String sessionCode = (String) request.getSession().getAttribute("vCode");
//二者进行比较看是否相等
System.out.println("validateVerifyCode is called"+verifyCode+":"+sessionCode);
boolean flag = sessionCode.equalsIgnoreCase(verifyCode);
response.getWriter().print(flag);
return null;
} /*
* 当用户从邮箱点击的激活的时候会调用该方法,并且把激活码传递过来
*
* */
public String activation(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub String activationCode = request.getParameter("activationCode");
System.out.println("email activationCode is :"+activationCode);
try {
service.activation(activationCode);
//激活成功
request.setAttribute("code", "success"); //msg.jsp已经code的值来显示错误信息还是正确的信息
request.setAttribute("msg", "激活成功");
return "f:/jsps/msg.jsp";
} catch (Exception e) {
//将业务操作的异常信息在msg.jsp中显示出来
String msg = e.getMessage();
request.setAttribute("code", "error"); //msg.jsp已经code的值来显示错误信息还是正确的信息
request.setAttribute("msg", msg);
return "f:/jsps/msg.jsp"; } } /*
* 当用户注册的时候会调用该方法
*
* */
public String regist(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("activation is called"); //1、将请求的参数封装成User对象
User user = CommonUtils.toBean(request.getParameterMap(), User.class);
//2 、对传递过来的参数进行校验,把错误的信息封装到一个hashMap中
Map errors = validateParams(user, request);
if(errors.size() > 0){//说明参数错误,跳转到注册界面提示用户输入的参数有误
request.setAttribute("errors", errors);
request.setAttribute("user", user);
return "f:/jsps/user/regist.jsp";
}
service.addUser(user);
request.setAttribute("code", "success");
request.setAttribute("msg", "用户注册成功,请马上到邮箱进行激活");
return "f:/jsps/msg.jsp"; } /*
* 当用户登录的时候会调用该方法
*
* */
public String login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("activation is called"); /*1、第一步将用户提交的参数封装成javabean对象
*
*2、对提交的参数的进行合法性的校验
*
*3、通过用户名和密码去查找得到user对象
*如果user对象为null,说明用户名和密码不正确,重定向到login.jsp提示用户名和密码错误
*如果user对象不为null,查看当前用户的激活状态,如果当前用户没有被激活,提示当前用户没有被激活,重定向到login.jsp提示
*如果user对象不为null,并且当前用户处于激活状态,把当前用户保存到session中,显示当前用户是谁
*为了实现页面自定功能,需要把用户名保存到cookie中,主要cookie不支持中文,需要对
*中文进行有效性的处理。
*
*
*
* */ User formUser = CommonUtils.toBean(request.getParameterMap(), User.class);
//对参数进行合法性的校验
//2 、对传递过来的参数进行校验,把错误的信息封装到一个hashMap中
Map errors = validateLoginParams(formUser, request);
if(errors.size() > 0){//说明参数错误,跳转到注册界面提示用户输入的参数有误
request.setAttribute("errors", errors);
request.setAttribute("user", formUser);
return "f:/jsps/user/login.jsp";
}
User user =service.login(formUser); //判断用户是否为null
if(user == null){
request.setAttribute("msg", "输入的用户名和密码不正确");
request.setAttribute("user", formUser);
return "f:/jsps/user/login.jsp";
}else{
if(0 == user.getStatus()){ //没有激活
request.setAttribute("msg", "当前用户没有激活,请先激活该用户");
request.setAttribute("user", formUser);
return "f:/jsps/user/login.jsp";
}
//说明用户登录成功
request.getSession().setAttribute("sessionUser", user);
//将用户名保存到cookie中,因为cookie不支持中文使用URL进行编码
Cookie cookie = new Cookie("cookieLoginName", URLEncoder.encode(user.getLoginname(), "utf-8"));
cookie.setMaxAge(60*60*24);//cookie的有效期是一天
//添加cookie对象,把cookier对象返回给浏览器
response.addCookie(cookie);
//登录成功之后客户端使用redict重新登录到index.jsp主页面
return "r:/index.jsp"; }
} public Map validateParams(User user,HttpServletRequest request){
Map<String, String> map = new HashedMap();
//校验用户名
String loginName = user.getLoginname();
if(loginName == null || loginName.isEmpty()){
map.put("loginname", "用户名不能为空");
}
if(loginName.length() < 3 || loginName.length() > 20){
map.put("loginname", "用户名长度应该在3到20之间");
}
//校验用户名是否注册
if(service.ajaxValidateLoginName(loginName)){
map.put("loginname", "用户名已经被注册");
} //检查登陆密码
String loginpass = user.getLoginpass();
if(loginpass == null || loginpass.isEmpty()){
map.put("loginpass", "登陆密码不能为空");
}
if(loginpass.length() < 3 || loginpass.length() > 20){
map.put("loginname", "登陆密码的长度应该在3到20之间");
} //检查确认密码的信息
//检查登陆密码
String reloginpass = user.getReloginpass();
if(reloginpass == null || reloginpass.isEmpty()){
map.put("reloginpass", "登陆密码不能为空");
}
if(reloginpass.length() < 3 || reloginpass.length() > 20){
map.put("reloginpass", "登陆密码的长度应该在3到20之间");
}
if(!reloginpass.equalsIgnoreCase(loginpass)){
map.put("reloginpass", "两次输入的密码不一样");
} //检查邮箱
String email = user.getEmail();
if(email == null || email.isEmpty()){
map.put("email", "登陆邮箱不能为空");
}
//检查邮箱的格式是否正确
if(!email.matches("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,3}){1,2})$")){
map.put("email", "邮箱格式不正确");
} //检查验证码是否相等
String verifyCode = user.getVerifyCode();
//获得session中保存的验证码
String sessionCode =(String) request.getSession().getAttribute("vCode");
if(!verifyCode.equalsIgnoreCase(sessionCode)){
map.put("verifyCode", "验证码不正确");
} return map; } public Map validateLoginParams(User user,HttpServletRequest request){
Map<String, String> map = new HashedMap();
//校验用户名
String loginName = user.getLoginname();
if(loginName == null || loginName.isEmpty()){
map.put("loginname", "用户名不能为空");
}
if(loginName.length() < 3 || loginName.length() > 20){
map.put("loginname", "用户名长度应该在3到20之间");
} //检查验证码是否相等
String verifyCode = user.getVerifyCode();
//获得session中保存的验证码
String sessionCode =(String) request.getSession().getAttribute("vCode");
if(!verifyCode.equalsIgnoreCase(sessionCode)){
map.put("verifyCode", "验证码不正确");
} return map; } /*
* 当用户修改密码的时候会调用该方法
* */
public String updatePassword(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { /*业务操作的流程
* 1、将请求的参数封装成javaBean对象
* 2、获得当前登录用户的uuid
* 3、利用uuid和原始的密码去查找用户是否存在
* 3、利用uuid去修改新的密码
*
* */
System.out.println("updatePassword is called");
User formUser = CommonUtils.toBean(request.getParameterMap(), User.class);
//如果用户登录成功了,会在session中保存该用户 User loginUser = (User) request.getSession().getAttribute("sessionUser");
if(loginUser == null){//说明当前用户没有登录,到pwd.jsp显示异常信息
request.setAttribute("msg", "用户没有登录,请先登录在修改用户密码");
return "f:/jsps/user/login.jsp";
}
try {
service.updateUserPassword(loginUser.getUid(), loginUser.getLoginpass(), formUser.getNewpass());
//说明修改密码成功
request.setAttribute("code", "success");
request.setAttribute("msg", "用户修改密码成功,请重新登录");
return "f:/jsps/msg.jsp";
} catch (Exception e) {
//修改密码失败
request.setAttribute("msg",e.getMessage());
return "f:/jsps/user/pwd.jsp";
} } }

因为登陆是到UserServlet的updatePassword中进行操作,所以需要在pwd.jsp页面配置

pwd.jsp的代码:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>pwd.jsp</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link rel="stylesheet" type="text/css" href="<c:url value='/css/css.css'/>">
<link rel="stylesheet" type="text/css" href="<c:url value='/jsps/css/user/pwd.css'/>">
<script type="text/javascript" src="<c:url value='/jquery/jquery-1.5.1.js'/>"></script>
<%--引入pwd.js文件 --%>
<script type="text/javascript" src="<c:url value='/jsps/js/user/pwd.js'/>"></script>
<script src="<c:url value='/js/common.js'/>"></script>
</head> <body>
<div class="div0">
<span>修改密码</span>
</div> <div class="div1">
<form action="<c:url value='/UserServlet'/>" method="post" target="_top">
<input type="hidden" name="method" value="updatePassword"/>
<table>
<tr>
<td><label class="error">${msg }</label></td>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td align="right">原密码:</td>
<td><input class="input" type="password" name="loginpass" id="loginpass" value=""/></td>
<td><label id="loginpassError" class="error"></label></td>
</tr>
<tr>
<td align="right">新密码:</td>
<td><input class="input" type="password" name="newpass" id="newpass" value=""/></td>
<td><label id="newpassError" class="error"></label></td>
</tr>
<tr>
<td align="right">确认密码:</td>
<td><input class="input" type="password" name="reloginpass" id="reloginpass" value=""/></td>
<td><label id="reloginpassError" class="error"></label></td>
</tr>
<tr>
<td align="right"></td>
<td>
<img id="vCode" src="/VerifyCodeServlet" border="1"/>
<a href="javascript:changeVerifyCode();">看不清,换一张</a>
</td>
</tr>
<tr>
<td align="right">验证码:</td>
<td>
<input class="input" type="text" name="verifyCode" id="verifyCode" value=""/>
</td>
<td><label id="verifyCodeError" class="error"></label></td>
</tr>
<tr>
<td align="right"></td>
<td><input id="submit" type="submit" value="修改密码"/></td>
</tr>
</table>
</form>
</div>
</body>
</html>

JavaWeb网上图书商城完整项目--day02-20.修改密码各层实现的更多相关文章

  1. JavaWeb网上图书商城完整项目--day02-4.regist页面提交表单时对所有输入框进行校验

    1.现在我们要将table表中的输入的参数全部提交到后台进行校验,我们提交我们是按照表单的形式提交,所以我们首先需要在table表外面添加一个表单 <%@ page language=" ...

  2. JavaWeb网上图书商城完整项目--24.注册页面的css样式实现

    现在框架已经做好了,即下来我们要对页面进行装饰了,第一步给每一个元素添加id 1.最外面的div添加id为divMain 2.第二个div添加id为divTitle,里面的span对应的id为span ...

  3. JavaWeb网上图书商城完整项目--day02-21.退出功能的实现

    1.当用户点击退出的时候,跳转到登陆页面 当用户点击退出的时候,需要将session中保存的登陆的用户销毁掉 当用户点击退出的时候,调用UserServlet的quit方法 退出按钮在top.jsp中 ...

  4. JavaWeb网上图书商城完整项目--day02-17.登录功能页面实现

    1.当在登陆页面点击登陆按钮的时候,会调用UserServlet的login方法,我们要在login.jsp中进行配置 2.要在login.jsp中处理Servlet在后台业务操作之后forward到 ...

  5. JavaWeb网上图书商城完整项目--day02-18.修改密码页面处理

    1.用户登陆成功之后会显示 当点击修改密码的时候,会进入下面的页面 对应的是pwd.jsp这个文件 我们把对jsp页面前段的校验都封装在pwd.js中,在jsp中引入该js文件 <%@ page ...

  6. JavaWeb网上图书商城完整项目--过滤器解决中文乱码

    我们知道,如果是POST请求,我们需要调用request.setCharacterEncoding(“utf-8”)方法来设计编码:如果是GET请求,我们需要自己手动来处理编码问题.如果我们使用了En ...

  7. JavaWeb网上图书商城完整项目--day02-12.激活功能各层实现

    1.我们来看程序的代码 数据库层: 1.通过激活码查找到对应的用户 2.设置用户的激活状态 2.业务层 1.通过数据库接口通过验证码得到对应的用户 2.判断当用户是否为空,如果没有通过激活码查找到对应 ...

  8. JavaWeb网上图书商城完整项目--day02-10.提交注册表单功能之页面实现

    1.当从服务器返回的注册错误信息的时候,我们在注册界面需要将错误信息显示出来 我们需要修改regist.jsp页面的代码:其中error是一个haspmap,c标签对map的属性可以直接使用 ${er ...

  9. JavaWeb网上图书商城完整项目--day02-9.提交注册表单功能之servlet层实现

    1.当用户在界面提交注册提交的时候,我们在UerServlet来实现具体的业务方法 标准demo: 1CommonUtils CommonUtils类就两个方法: lString uuid():生成长 ...

随机推荐

  1. [安卓基础] 007.管理Activity的生命周期

    *:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...

  2. 自己的win7第一次使用RabbitMQ

    使用的过程中参考了https://www.cnblogs.com/longlongogo/p/6489574.html所写的内容 一.环境搭建 1.由于RabbitMQ使用Erlang语言编写,所以先 ...

  3. NodeJS——在Sublime中配置NodeJS执行环境

    这种方式比在DOS窗中直接执行更加高效!!! nodejs 1.运行Sublime,菜单上找到Tools ---> Build System ---> new Build System 2 ...

  4. Linux passwd 提权

    利用条件,passwd 可写 ls -al /etc/passwd 利用方式: 生成密钥  openssl passwd -1 -salt test 123456 写入passwd echo 'tes ...

  5. 使用turtle库绘制一个红色五角星图形‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪

    import turtle n = eval(input("请输入五角星的长度")) turtle.begin_fill() #开始填充颜色 i = 0 while i < ...

  6. Java实现蓝桥杯 算法训练 ALGO-15 旅行家的预算

    问题描述 一个旅行家想驾驶汽车以最少的费用从一个城市到另一个城市(假设出发时油箱是空的).给定两个城市之间的距离D1.汽车油箱的容量C(以升为单位).每升汽油能行驶的距离D2.出发点每升汽油价格P和沿 ...

  7. (Java实现) 有重复元素排列问题

    有重复元素的排列问题 [问题描述] 设R={ r1, r2 , -, rn}是要进行排列的n个元素.其中元素r1, r2 , -, rn可能相同.试设计一个算法,列出R的所有不同排列. [编程任务] ...

  8. Java实现蓝桥杯历届试题回文数字

    历届试题 回文数字 时间限制:1.0s 内存限制:256.0MB 提交此题 问题描述 观察数字:12321,123321 都有一个共同的特征,无论从左到右读还是从右向左读,都是相同的.这样的数字叫做: ...

  9. Java实现 LeetCode 374 猜数字大小 II

    375. 猜数字大小 II 我们正在玩一个猜数游戏,游戏规则如下: 我从 1 到 n 之间选择一个数字,你来猜我选了哪个数字. 每次你猜错了,我都会告诉你,我选的数字比你的大了或者小了. 然而,当你猜 ...

  10. Java实现第十届蓝桥杯数列求值

    试题 C: 数列求值 本题总分:10 分 [问题描述] 给定数列 1, 1, 1, 3, 5, 9, 17, -,从第 4 项开始,每项都是前 3 项的和.求 第 20190324 项的最后 4 位数 ...