Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
springBoot
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WitCloud
springBoot
Commits
9ded52d3
Commit
9ded52d3
authored
Jan 20, 2017
by
杨伊博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
security is ok
parent
282c99b1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
8 deletions
+12
-8
pom.xml
springboot-security/pom.xml
+6
-0
HomeController.java
...c/main/java/com/us/example/controller/HomeController.java
+0
-1
SysUser.java
...security/src/main/java/com/us/example/domain/SysUser.java
+1
-1
home.html
springboot-security/src/main/resources/templates/home.html
+5
-6
No files found.
springboot-security/pom.xml
View file @
9ded52d3
...
...
@@ -34,6 +34,12 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
</dependency>
<dependency>
<groupId>
org.thymeleaf.extras
</groupId>
<artifactId>
thymeleaf-extras-springsecurity4
</artifactId>
</dependency>
<!--db-->
<dependency>
<groupId>
mysql
</groupId>
...
...
springboot-security/src/main/java/com/us/example/controller/HomeController.java
View file @
9ded52d3
...
...
@@ -17,5 +17,4 @@ public class HomeController {
model
.
addAttribute
(
"msg"
,
msg
);
return
"home"
;
}
}
springboot-security/src/main/java/com/us/example/domain/SysUser.java
View file @
9ded52d3
...
...
@@ -6,7 +6,7 @@ import java.util.List;
* Created by yangyibo on 17/1/17.
*/
public
class
SysUser
{
//用户实体实现UserDetails接口,我门的用户实体即位 security 所使用的用户
public
class
SysUser
{
private
Integer
id
;
private
String
username
;
private
String
password
;
...
...
springboot-security/src/main/resources/templates/home.html
View file @
9ded52d3
<!DOCTYPE html>
<html
xmlns:th=
"http://www.thymeleaf.org"
xmlns:sec=
"http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"
>
<!-- 1 -->
xmlns:sec=
"http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"
>
<head>
<meta
content=
"text/html;charset=UTF-8"
/>
<title
sec:authentication=
"name"
></title>
<!-- 2 -->
<title
sec:authentication=
"name"
></title>
<link
rel=
"stylesheet"
th:href=
"@{css/bootstrap.min.css}"
/>
<style
type=
"text/css"
>
body
{
...
...
@@ -24,7 +24,6 @@ body {
<div
id=
"navbar"
class=
"collapse navbar-collapse"
>
<ul
class=
"nav navbar-nav"
>
<li><a
th:href=
"@{/}"
>
首页
</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
...
...
@@ -38,16 +37,16 @@ body {
<p
class=
"bg-primary"
th:text=
"${msg.content}"
></p>
<div
sec:authorize=
"hasRole('ROLE_ADMIN')"
>
<!--
3
-->
<div
sec:authorize=
"hasRole('ROLE_ADMIN')"
>
<!--
用户类型为ROLE_ADMIN 显示
-->
<p
class=
"bg-info"
th:text=
"${msg.etraInfo}"
></p>
</div>
<div
sec:authorize=
"hasRole('ROLE_USER')"
>
<!--
4
-->
<div
sec:authorize=
"hasRole('ROLE_USER')"
>
<!--
用户类型为 ROLE_USER 显示
-->
<p
class=
"bg-info"
>
无更多信息显示
</p>
</div>
<form
th:action=
"@{/logout}"
method=
"post"
>
<input
type=
"submit"
class=
"btn btn-primary"
value=
"注销"
/>
<!-- 5 -->
<input
type=
"submit"
class=
"btn btn-primary"
value=
"注销"
/>
</form>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment