SSM實現的一套用戶登錄注冊系統,附帶驗證等功能(使用idea開發)


未登錄時的界面:

在這里插入圖片描述
登錄和注冊界面,有動態效果:
在這里插入圖片描述
在這里插入圖片描述
登陸之后的界面
在這里插入圖片描述
在這里插入圖片描述
擁有完善的驗證功能

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM