-
Notifications
You must be signed in to change notification settings - Fork 122
A、快速开始
wangjie edited this page Dec 24, 2019
·
10 revisions
创建springboot web 应用
<dependency>
<groupId>org.jsets</groupId>
<artifactId>jsets-shiro-spring-boot-starter</artifactId>
<version>1.1.0</version>
</dependency>
由于还没有maven坐标您可以将载源下载到本地或者直接下载jar包然后上传至本地仓库。
#jsets-shiro配置
jsets:
shiro:
login-url: /login #登陆地址
login-success-url: /index #登陆成功后,跳转的页面
filte-rules: # 过滤规则
- /assets/**-->anon # anon 表示不进行鉴权
- /login/**-->authc # 表示满足'/login/**'的地址使用authc(登录)过滤器
- /logout/**-->logout # 表示满足'/logout/**'的地址使用logout(登出)过滤器
- /**-->user #表示满足'/**'的地址使用user(是否登录)过滤器
@Controller
public class IndexAction {
@RequestMapping("/")
public String def() {
return "index";
}
@RequestMapping("/index")
public String index() {
return "index";
}
@RequestMapping("/login")
public String login() {
return "login";
}
}
<form class="login-form" action="${ctx}/login" method="post">
<div class="form-item">
用户名:<input type="text" name="username" />
</div>
<div class="form-item">
密码:<input type="password" name="password" />
</div>
<div class="form-item">
<button type="submit">登录</button>
</div>
</form>
<!-- 认证信息 -->
<font color="red">${Request["shiro_auth_message"]!}</font>
<div class="body">
欢迎您:${Session.shiro_current_user.account!}
<br>
退出:<a href="${ctx}/logout">退了</a>
</div>
@SpringBootApplication
@EnableJsetsShiro
public class Application{
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
启动springboot应用,使用用户名test,密码test就可以登录了。
这仅仅是一个简单的快速体验DEMO,更完整的示例请参考: