未登录时的界面:
登录和注册界面,有动态效果:
登陆之后的界面
拥有完善的验证功能
package com.yue.service;
import com.yue.mapper.UserMapper;
import com.yue.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
@Service("UserService")
public class UserServiceImpl implements UserService{
@Autowired
private UserMapper userMapper;
public void addUser(User user) {
User exituser = userMapper.getUserByUsername(user.getUser_username());
if(user.getUser_username().trim()=="") throw new RuntimeException("账号不可为空!!!");
if(user.getUser_name().trim()=="") throw new RuntimeException("昵称不可为空!!!");
if(user.getUser_password().trim()=="") throw new RuntimeException("密码不可为空!!!");
if(exituser!=null){
throw new RuntimeException("账号已存在");
}else{
userMapper.addUser(user);
}
}
public User login(User user) {
User exituser = userMapper.getUserByUsername(user.getUser_username());
if(user.getUser_username().trim()=="") throw new RuntimeException("账号不可为空!!!");
if(user.getUser_password().trim()=="") throw new RuntimeException("密码不可为空!!!");
if(exituser==null){
throw new RuntimeException("账号不存在!!!");
}
if(exituser.getUser_password().equals(user.getUser_password())){
return exituser;
}else{
throw new RuntimeException("密码错误!!!");
}
}
public void updataUser(String user_username, String user_password1, String user_password2, String user_password3) {
User user = userMapper.getUserByUsername(user_username);
System.out.println(user);
if(!user.getUser_password().equals(user_password1)){
throw new RuntimeException("旧密码输入不正确!");
}
if(!user_password2.equals(user_password3)){
throw new RuntimeException("两次输入的密码不同!");
}
user.setUser_password(user_password2);
System.out.println(user);
userMapper.updataUser(user);
}
}
数据库创建代码在实体类中
源码链接
https://download.csdn.net/download/weixin_44284599/12273296
https://gitee.com/yueliu2345/UserSystem