使用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
|
@Controllerpublic 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 ...
随机推荐
- PL/SQL Developer安装配置
选择tool下的perferences 修改下面标记的内容即可
- Python3 数据库连接
PyMySQL是在Python3.x版本中用于连接MySQL服务器的一个库,Python2中使用mysqldb. 数据库连接 连接数据库前,请先确认一下事项: 已经创建数据库testdb. 在test ...
- DLL.LoadLibrary失败(126)
1.LoadLibrary 返回 NULL,GetLastError 显示的是 错误码126,msdn上是这样的: ERROR_MOD_NOT_FOUND 126 (0x7E) The specifi ...
- [转][C++]佛祖保佑,永无bug。C++ BUG解决方案
// // _oo0oo_ // o8888888o // 88" . "88 // (| -_- |) // 0\ = /0 // ___/`---'\___ // .' \\| ...
- 你想了解Go语言开发吗?
大家先了解一下什么是Go语言? Go语言是谷歌2009发布的第二款开源编程语言.Go语言专门针对多处理器系统应用程序的编程进行了优化,使用Go编译的程序可以媲美C或C++代码的速度,而且更加安全.支持 ...
- JqueryValidate 表单验证插件
1.适用场景 表单 ( 支持自定义规则 ) 2.相关文章 jQuery Validate 3.实际问题 JqueryValidate表单相同Name不校验问题解决
- springboot---->获取不到yml配置文件指定的值
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.Spr ...
- C#如何实现类似QQ那样靠边隐藏的功能
http://www.cnblogs.com/yechensi/archive/2009/08/02/1537145.html C#如何实现类似QQ那样靠边隐藏的功能 你想过为自己的程序添加靠边隐藏的 ...
- 字符串hash
hash[i]=(hash[i-1]*p+idx(s[i]))%mod p和mod取不同的较大的素数
- android ------- 运行官方NDK 案例HelloJNI
下载案例 HelloJNI ,导入工程到Eclipse, 可以直接下载我的案例, 源码下载:https://github.com/DickyQie/android-ndk 目录图 使用命令生成 . ...