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 ,password ,rememberMe)
因为在 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、
来源:oschina
链接:https://my.oschina.net/u/4389538/blog/4483480