栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

基于SSM框架的简易销消系统(用户登录注册 增删改查等)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

基于SSM框架的简易销消系统(用户登录注册 增删改查等)

基于SSM框架的简易销消系统(用户登录注册 增删改查等)——使用layui插件 整体结构

前端页面


login.jsp
<%--
  Created by IntelliJ IDEA.
  User: 晓晓
  Date: 2022/4/20
  Time: 12:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>



    
    后台登录-X-admin2.0
    
    
    
    

    
    
    
    
    
    













index.jsp
<%--
  Created by IntelliJ IDEA.
  User: 晓晓
  Date: 2022/4/21
  Time: 13:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" import="jxc.tj.ssm.domain.SysUser" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>



    
    小谭的销消系统
    
    
    
    

    
    
    
    
    
    












  • 我的桌面
add.jsp
<%--
  Created by IntelliJ IDEA.
  User: 晓晓
  Date: 2022/4/20
  Time: 18:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>



    
    欢迎页面-X-admin2.0
    
    
    

    
    
    
    
    
    
    
    


*
*将会成为您唯一的登入名
6到16个字符
/> />
detail.jsp
<%--
  Created by IntelliJ IDEA.
  User: 晓晓
  Date: 2022/4/20
  Time: 23:40
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>



    
    详情
    
    
    

    <%--    --%>
    
    
    
    
    
    
    


*
*将会成为您唯一的登入名
6到16个字符
/> />
edit.jsp
<%--
  Created by IntelliJ IDEA.
  User: 晓晓
  Date: 2022/4/20
  Time: 18:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>



    
    编辑
    
    
    

    <%--    --%>
    
    
    
    
    
    
    


*
*将会成为您唯一的登入名
6到16个字符
/> />
list.jsp
<%--
  Created by IntelliJ IDEA.
  User: 晓晓
  Date: 2022/4/20
  Time: 11:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>




    
    用户列表
    
    
    

    
    
    
    
    
    
    
    <%--    [if lt IE 9]>--%>
    <%--    --%>
    <%--    --%>
    <%--    




<%-- --%> <%-- --%>
ID 用户名 登录账号 状态 操作
${item.id} ${item.name} ${item.account} 已启用 禁用
1 2 3 489
后端

pom.xml



  4.0.0

  org.example
  Experiment13
  1.0-SNAPSHOT
  war

  Experiment13 Maven Webapp
  
  http://www.example.com

  
    UTF-8
    
    5.2.15.RELEASE
    
    3.3.0
    
    1.7.24
    1.2.17

    
    
  

  
    
    
      org.springframework
      spring-core
      5.3.17
    
    
      org.springframework
      spring-web
      5.3.17
    
    
      org.springframework
      spring-oxm
      5.3.17
    
    
      org.springframework
      spring-tx
      4.3.7.RELEASE
    
    
      org.springframework
      spring-jdbc
      4.3.7.RELEASE
    
    
      org.springframework
      spring-webmvc
      5.3.17
    
    
      org.springframework
      spring-aop
      5.3.17
    

    
      org.springframework
      spring-context-support
      5.3.17
    
    
      org.springframework
      spring-test
      5.3.17
    
    

    
    
      org.mybatis
      mybatis
      3.5.3
    

    
    
      org.mybatis
      mybatis-spring
      2.0.3
    

    
    
      mysql
      mysql-connector-java
      8.0.28
    
    
    
      com.alibaba
      druid
      1.2.5
    

    
    
      junit
      junit
      4.11
      test
    

    
    
      javax.servlet
      jstl
      1.2
    
    
      javax.servlet.jsp
      jsp-api
      2.2.1-b03
      provided
    

    
    
      javax.servlet
      javax.servlet-api
      3.1.0
      provided
    
    
      com.fasterxml.jackson.core
      jackson-core
      2.13.2
    
    
      com.fasterxml.jackson.core
      jackson-annotations
      2.13.2
    
    
      com.fasterxml.jackson.core
      jackson-databind
      2.13.2
    
    
      net.sf.json-lib
      json-lib
      2.4
      jdk15
    
    
      commons-lang
      commons-lang
      2.4
    
    
      commons-logging
      commons-logging
      1.2
    
    
      commons-pool
      commons-pool
      1.6
    
    
      commons-dbcp
      commons-dbcp
      1.4
    
    
      commons-beanutils
      commons-beanutils
      1.9.3
    

    
      commons-httpclient
      commons-httpclient
      3.1
    
    
      commons-collections
      commons-collections
      3.2.2
    
    
      commons-codec
      commons-codec
      1.9
    
    
      javax.annotation
      jsr250-api
      1.0
    
    
      net.sf.ezmorph
      ezmorph
      1.0.6
    
    
      javax.activation
      activation
      1.1.1
    
    
      taglibs
      standard
      1.1.2
    

    
    
    
      log4j
      log4j
      1.2.17
    

    
      org.slf4j
      slf4j-api
      1.7.24
    
    
      org.slf4j
      slf4j-log4j12
      1.7.24
    


    
      commons-fileupload
      commons-fileupload
      1.4
    
    
      commons-io
      commons-io
      2.11.0
    
    
      org.projectlombok
      lombok
      1.18.22
    
  

  
    Experiment13
    
      
        
          maven-clean-plugin
          3.1.0
        
        
        
          maven-resources-plugin
          3.0.2
        
        
          maven-compiler-plugin
          3.8.0
        
        
          maven-surefire-plugin
          2.22.1
        
        
          maven-war-plugin
          3.2.2
        
        
          maven-install-plugin
          2.5.2
        
        
          maven-deploy-plugin
          2.8.2
        
      
    
  


web.xml




    Experiment13

    
        encodingFilter
        org.springframework.web.filter.CharacterEncodingFilter
        
            encoding
            UTF-8
        
        
            forceEncoding
            true
        
    

    
        encodingFilter
        /*
    

    
    
        springServlet
        org.springframework.web.servlet.DispatcherServlet
        
            contextConfigLocation
            classpath:applicationContent.xml
        
        1
    

    
        springServlet
        /
    
    
    
        
            org.springframework.web.context.ContextLoaderListener
        
    

    
    
        default
        *.md
    
    
        contextConfigLocation
        classpath:applicationContent.xml
    
    
    

                https://blog.csdn.net/m0_58828100/article/details/views/home/index.jsp

    
    
    
    
    
    
    
    
        600
    




applicationContent.xml


    
    

    
    
    
    
    
    
    
    

    
    
        
        
        
    
    
    
        
            
                classpath:jdbc.properties
            
        
    
    
        
        
        
        
        
        
    
    
    
        
        
        
        
        
        
        
        
        
        
        
        
        
    
    
    
        
        
        
    
    
    
        
    
    
    
        
        

    










sysUserController.java
package jxc.tj.ssm.controller;

import jxc.tj.ssm.domain.SysUser;

import jxc.tj.ssm.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;


import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller

public class SysUserController {
    @Autowired
    private SysUserService sysUserService;
//    用户登录-get
    @GetMapping("/login")
    public String login(){
        return "/sysUser/login";
    }

    @RequestMapping("/index")
    public String index(){
        return "/home/index";
    }
//199000334 tanjia谭佳
    //用户登录-post
    @PostMapping("/login")
    @ResponseBody
    public String login(SysUser sysUser, HttpServletRequest request) {
        try{
            SysUser find = sysUserService.checkLogin(sysUser);
//        SysUser find = sysUserService.checkLogin(sysUser.getAccount(),sysUser.getPassword());
            if (find != null && find.getStatus() == 0) {
                request.getSession().setAttribute("loginUser", find);
                request.getSession().setAttribute("account", find.getAccount());
                return "ok";
            } else return "error";
        } catch (Exception e) {
            return e.getMessage();
        }
    }

    //注销
    @RequestMapping("https://blog.csdn.net/loginOut")
    public String loginOut(HttpServletRequest request){
        request.getSession().removeAttribute("loginUser");
        System.out.println("退出登录");
        return "sysUser/login";
    }

    //列表-未分页
    @RequestMapping("/list")
    public String list(Model model) {
        System.out.println("sysUser list");
        List list = sysUserService.selectAll();
        System.out.println(list);
        model.addAttribute("userList",list);
        return "sysUser/list";
    }

//  查找-post

    //新增-get
    @GetMapping("/add")
    public String add(Model model){
        SysUser entity=new SysUser();
        entity.setStatus(0);
        model.addAttribute("item",entity);
        return "/sysUser/add";
    }

    //新增-post
    @PostMapping("/add")
    @ResponseBody
    public String add(SysUser entity){
        try {
            //TODO:增补密码加密存储
            sysUserService.insert(entity);
            System.out.println("添加成功");
            return "ok";
        } catch (Exception e) {
            return e.getMessage();
        }
    }

    //删除
    @RequestMapping("/delete")
    @ResponseBody
    public String delete(int id){
        try {
            sysUserService.deleteByPrimaryKey(id);
            return "ok";
        } catch (Exception e) {
            return e.getMessage();
        }
    }

    //修改-get
    @GetMapping("/edit")
    public String edit(int id, HttpServletRequest request,Model model){
        SysUser entity=sysUserService.selectByPrimaryKey(id);
        model.addAttribute("item",entity);
        return "/sysUser/edit";
    }
    //修改-post
    @PostMapping("/edit")
    @ResponseBody
    public String edit(SysUser entity){
        try {
            sysUserService.updateByPrimaryKey(entity);
            return "ok";
        } catch (Exception e) {
            return e.getMessage();
        }
    }

    //查看详情
    @RequestMapping("/detail")
    public String detail(int id,Model model){
        SysUser entity=sysUserService.selectByPrimaryKey(id);
        model.addAttribute("item",entity);
        return "/sysUser/detail";
    }
}

拦截器
package jxc.tj.ssm.Interceptor;


import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class LoginInterceptor implements HandlerInterceptor {
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
        String url=request.getRequestURI();
        if (url.indexOf("/login")>=0||url.indexOf("/login")>=0){
            System.out.println(url+"放行");
            return true;
        }
        System.out.println("当前访问地址:"+url);
        Object account=request.getSession().getAttribute("account");
        if(account==null){
            System.out.println("用户未登录,请登录");
            response.sendRedirect(request.getContextPath()+"/login");
            return false;
        }
        return true;
    }
}

效果图





转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/914658.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号