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
f7c4888d
Commit
f7c4888d
authored
Apr 26, 2017
by
杨伊博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify thymeleaf permission
parent
8994781a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
21 deletions
+10
-21
WebMvcConfig.java
...ity/src/main/java/com/us/example/config/WebMvcConfig.java
+0
-17
WebSecurityConfig.java
...rc/main/java/com/us/example/config/WebSecurityConfig.java
+4
-3
HomeController.java
...c/main/java/com/us/example/controller/HomeController.java
+4
-0
login.html
springboot-security/src/main/resources/templates/login.html
+2
-1
No files found.
springboot-security/src/main/java/com/us/example/config/WebMvcConfig.java
deleted
100644 → 0
View file @
8994781a
package
com
.
us
.
example
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.ViewControllerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
/**
* Created by yangyibo on 17/1/18.
*/
@Configuration
public
class
WebMvcConfig
extends
WebMvcConfigurerAdapter
{
@Override
public
void
addViewControllers
(
ViewControllerRegistry
registry
)
{
// registry.addViewController("/login").setViewName("login");
}
}
springboot-security/src/main/java/com/us/example/config/WebSecurityConfig.java
View file @
f7c4888d
...
...
@@ -36,17 +36,18 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
()
.
antMatchers
(
"/
index.js.map
"
).
permitAll
()
.
antMatchers
(
"/
css/**
"
).
permitAll
()
.
anyRequest
().
authenticated
()
//任何请求,登录后可以访问
.
and
()
.
formLogin
()
.
loginPage
(
"/login"
)
.
defaultSuccessUrl
(
"/"
)
.
failureUrl
(
"/login?error"
)
.
permitAll
()
//登录页面用户任意访问
.
and
()
.
logout
().
permitAll
();
//注销行为任意访问
http
.
addFilterBefore
(
myFilterSecurityInterceptor
,
FilterSecurityInterceptor
.
class
);
}
}
springboot-security/src/main/java/com/us/example/controller/HomeController.java
View file @
f7c4888d
...
...
@@ -19,6 +19,10 @@ public class HomeController {
return
"home"
;
}
@RequestMapping
(
"/login"
)
public
String
login
(){
return
"login"
;
}
@RequestMapping
(
"/admin"
)
@ResponseBody
...
...
springboot-security/src/main/resources/templates/login.html
View file @
f7c4888d
<!DOCTYPE html>
<html
xmlns:th=
"http://www.thymeleaf.org"
>
<html
xmlns:th=
"http://www.thymeleaf.org"
xmlns:sec=
"http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"
>
<head>
<meta
content=
"text/html;charset=UTF-8"
/>
<title>
登录页面
</title>
...
...
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