码迷,mamicode.com
首页 > 编程语言 > 详细

springboot+Shiro+登录

时间:2020-01-01 15:13:23      阅读:62      评论:0      收藏:0      [点我收藏+]

标签:登录   password   htm   相关   密码   xtend   dep   control   name   

1、springboot+Shiro+登录

2、引入相关支持

        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-core</artifactId>
            <version>1.4.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-web</artifactId>
            <version>1.4.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-spring</artifactId>
            <version>1.4.2</version>
        </dependency>

 

3、HTML配置(这里的用户名 密码 等信息字段名称必须是如下:username ,passwordrememberMe

因为在 FormAuthenticationFilter中固定了这些信息:源码如下:

public class FormAuthenticationFilter extends AuthenticatingFilter {

    //TODO - complete JavaDoc

    public static final String DEFAULT_ERROR_KEY_ATTRIBUTE_NAME = "shiroLoginFailure";

    public static final String DEFAULT_USERNAME_PARAM = "username";
    public static final String DEFAULT_PASSWORD_PARAM = "password";
    public static final String DEFAULT_REMEMBER_ME_PARAM = "rememberMe";

html

<form name="login_name" target="_self" action="/zhongqiu/systemLogin" method="post"> 
                    <div class="input-group form-group">
                        <span class="input-group-addon">
                            <span class="glyphicon glyphicon-user"></span>
                        </span>
                        <input type="text" id="username" name="username" class="form-control" placeholder="请输入用户名">
                    </div>
                    <div class="input-group form-group">
                        <span class="input-group-addon">
                            <span class="glyphicon glyphicon-lock"></span>
                        </span>
                        <input type="password" id="password" name="password" class="form-control" placeholder="请输入密码">
                    </div>
                     <div class="row align-items-center remember">
                        <input type="checkbox" id="rememberMe">记住我
                    </div>
                    <div class="form-group" id="btnstyle">
                        <button type="submit" value="登录" class="btn float-right login_btn">登录</button>
                    </div>
                </form>

 

4、Controller配置

 

5、springboot配置

6、

springboot+Shiro+登录

标签:登录   password   htm   相关   密码   xtend   dep   control   name   

原文地址:https://www.cnblogs.com/ywf520/p/12128805.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!