使用Spring Security安全控制(二十六)
准备工作
首先,构建一个简单的Web工程,以用于后续添加安全控制,也可以用之前Chapter3-1-2做为基础工程。若对如何使用Spring Boot构建Web应用,可以先阅读《Spring Boot开发Web应用》一文。
Web层实现请求映射
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
@Controller public class HelloController { @RequestMapping ( "/" ) public String index() { return "index" ; } @RequestMapping ( "/hello" ) public String hello() { return "hello" ; } } |
/
:映射到index.html/hello
:映射到hello.html
实现映射的页面
- src/main/resources/templates/index.html
12345678910
<!DOCTYPE html>
<html xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:th=
"http://www.thymeleaf.org"
xmlns:sec=
"http://www.thymeleaf.org/thymeleaf-extras-springsecurity3"
>
<head>
<title>Spring Security入门</title>
</head>
<body>
<h1>欢迎使用Spring Security!</h1>
<p>点击 <a th:href=
"@{/hello}"
>这里</a> 打个招呼吧</p>
</body>
</html>
- src/main/resources/templates/hello.html
12345678910
<!DOCTYPE html>
<html xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:th=
"http://www.thymeleaf.org"
xmlns:sec=
"http://www.thymeleaf.org/thymeleaf-extras-springsecurity3"
>
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>
可以看到在index.html中提供到
/hello
的链接,显然在这里没有任何安全控制,所以点击链接后就可以直接跳转到hello.html页面。
使用Spring Security安全控制(二十六)的更多相关文章
- Spring Security(二十六):8. Spring Security Community
8.1 Issue Tracking Spring Security uses JIRA to manage bug reports and enhancement requests. If you ...
- Spring Security(二十九):9.4.1 ExceptionTranslationFilter
ExceptionTranslationFilter is a Spring Security filter that has responsibility for detecting any Spr ...
- Spring Security(三十六):12. Spring MVC Test Integration
Spring Security provides comprehensive integration with Spring MVC Test Spring Security提供与Spring MVC ...
- Spring Security(二十八):9.4 Authentication in a Web Application
Now let’s explore the situation where you are using Spring Security in a web application (without we ...
- Spring Security(二十五):7. Sample Applications
There are several sample web applications that are available with the project. To avoid an overly la ...
- Spring Security(二十四):6.6 The Authentication Manager and the Namespace
The main interface which provides authentication services in Spring Security is the AuthenticationMa ...
- Spring Security(二十二):6.4 Method Security
From version 2.0 onwards Spring Security has improved support substantially for adding security to y ...
- Spring Security(二十):6.2.3 Form and Basic Login Options
You might be wondering where the login form came from when you were prompted to log in, since we mad ...
- 二十六:Struts2 和 spring整合
二十六:Struts2 和 spring整合 将项目名称为day29_02_struts2Spring下的scr目录下的Struts.xml文件拷贝到新项目的scr目录下 在新项目的WebRoot-- ...
- Spring Security 解析(二) —— 认证过程
Spring Security 解析(二) -- 认证过程 在学习Spring Cloud 时,遇到了授权服务oauth 相关内容时,总是一知半解,因此决定先把Spring Security .S ...
随机推荐
- Web Api:基于RESTful标准
参考链接:http://www.cnblogs.com/lori/p/3555737.html 简单的了解到RESTful架构后,跟着以上链接做了一个小练习. Step1: 新建WebApi项目,新建 ...
- hdu 1392 Surround the Trees 凸包裸题
Surround the Trees Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- ubuntu16系统磁盘空间/dev/vda1占用满的问题
参考文档: https://www.cnblogs.com/moonandstar08/p/6091507.html (系统磁盘空间/dev/xvda1占满原因分析) https://blog.csd ...
- [原][粒子特效][spark]插值器interpolator
深入浅出spark粒子特效连接:https://www.cnblogs.com/lyggqm/p/9956344.html 插值器是体现粒子生命周期变化的功能 group使用到插值器的方式: 可以看到 ...
- 力扣(LeetCode)412. Fizz Buzz
写一个程序,输出从 1 到 n 数字的字符串表示. 如果 n 是3的倍数,输出"Fizz": 如果 n 是5的倍数,输出"Buzz": 3.如果 n 同时是3和 ...
- C#获取路径中最后一个文件夹的名字
using System; using System.IO; namespace ConsoleApplication1 { class Program { static void Main(stri ...
- python实现邮件接口——smtplib模块
1. 思路 使用脚本发送邮件的思路其实和客户端发送邮件一样,过程都是: 登录 —> 写邮件 —> 发送 只不过通过脚本发送时我们需要考虑到整个过程的方方面面.以下为思路导图: 2. Pyt ...
- (转)Nandflash读写
------------------------------------------------------------------------------------------文章1------- ...
- [JSP] Action Tags
1.: forward转发请求to another resource (可能是jsp, html,等). 语法: <jsp:forward page="relativeURL | &l ...
- 使用absolute布局
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...