zoukankan      html  css  js  c++  java
  • SpringBoot实现登陆

    1、依赖

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.2.1.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.zn</groupId>
        <artifactId>springboot_invoicing</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>springboot_invoicing</name>
        <description>Demo project for Spring Boot</description>
    
        <properties>
            <java.version>1.8</java.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.junit.vintage</groupId>
                        <artifactId>junit-vintage-engine</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </dependency>
            <!-- 核心依赖 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <!-- 可以实现热部署,在IDEA上实现热部署还需一些额外的配置,请查阅资料 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
                <optional>true</optional>
                <scope>runtime</scope>
            </dependency>
    
            <!-- JDBC for mysql -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <scope>runtime</scope>
            </dependency>
    
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.32</version>
            </dependency>
    
            <!-- mybatis -->
            <!--mybatis-->
            <!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
            <dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>1.3.1</version>
            </dependency>
    
            <!--fastJson-->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>1.2.12</version>
            </dependency>
            <!--druid-->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid</artifactId>
                <version>1.0.18</version>
            </dependency>
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
                <version>3.4.1</version>
            </dependency>
            <!--thymeleaf  新的模板引擎,比jsp要出色-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-thymeleaf</artifactId>
            </dependency>
            <!--jdbc-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
            </dependency>
    
            <!-- 分页插件 -->
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper-spring-boot-starter</artifactId>
                <version>1.2.3</version>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
            <!--xml配置,此是为了将来整合Hibernate或者mybatis 默认没有需要配置-->
            <resources>
                <resource>
                    <directory>src/main/java</directory>
                    <includes>
                        <include>**/*.properties</include>
                        <include>**/*.xml</include>
                    </includes>
                </resource>
            </resources>
        </build>
    
    </project>
    View Code

    2、配置application.properties

        

    3、登陆页面 login.html

    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <title>系统登录 - 小型进销存系统</title>
       <!-- <link rel="stylesheet" href="css/style.css"/>-->
        <style>
            #parent{
                width:500px;
                height:200px;
                margin-top:20%;
                margin-left:50%;
                transform:translate(-50%,-50%) ;
                background:#009688;
            }
            .password,.subBtn{
                margin-top: 2%;
                margin-left: 3%;
            }
            .loginHeader{
                padding-top: 1%;
            }
        </style>
    </head>
    <body class="login_bg">
    <div id="parent">
        <section class="loginBox">
            <header class="loginHeader" style="text-align:center; ">
                <h1>小型进销存系统</h1>
            </header>
            <section class="loginCont">
                <form class="loginForm" action="/user/login" method="post" onsubmit="return check()" >
                    <div class="inputbox"  style="text-align:center; ">
                        <label for="user">用户名:</label>
                        <input id="user" type="text" name="userName" placeholder="请输入用户名" required="required" />
                    </div>
                    <div class="password"  style="text-align:center; " >
                        <label for="mima">密码:</label>
                        <input id="mima" type="password" name="password" placeholder="请输入密码" required="required" />
                    </div>
                    <div class="subBtn"  style="text-align:center; ">
                        <input type="submit" value="登录" />
                        <input type="reset" value="重置"/>
                    </div>
                </form>
            </section>
        </section>
    </div>
    </body>
    </html>
    View Code

    4、实体类

        

    5、dao层UserDao

        

    6、UserDao.xml

        

     7、UserService

        

     8、UserServiceImpl

        

     9、controller

        

     10、SpringbootInvoicingApplication

        

  • 相关阅读:
    【一句日历】2020年3月
    写给我们项目总监的一些话
    基于ajax 的 几个例子 session ,ajax 实现登录,验证码 ,实现ajax表单展示
    day 51 随机验证码, 验证登陆 ,以及 装饰器在函数中的应用
    day 51 cooike 与 session
    day 50 AJAX 初入门
    day 38 jq 入门 学习(一)
    转的大佬的 学习方法
    day 49 数据分析, 数据聚合 F 查询 Q 查询
    day 48 ORM 进阶 多表连接 创建 以及 html模板继承
  • 原文地址:https://www.cnblogs.com/Zzzzn/p/11989094.html
Copyright © 2011-2022 走看看