使用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 ...
随机推荐
- oracle 存储过程给另一个用户的权限问题
grant execute on (包名)存储过程名称 to 用户名; grant debug on (包名)存储过程名称 to 用户名 grant select on 存储过程名称 to 用户名 ...
- Git Gui 常见错误
- leecode第四十六题(全排列)
class Solution { public: vector<vector<int>> permute(vector<int>& nums) { int ...
- 学习笔记46—如何使Word和EndNote关联
1)打开Word文件项目中的选项,然后点击加载项, 2)找到Endnote安装目录,选择目录中的Configure EndNote.exe,选中configuration endnote compon ...
- cocos2dx 如何获得节点的类型
1. 需求:在所有子节点中得到是ui::Text类型的节点,并对其进行操作. 2. 解决方案:在根节点Node中有一个如下的函数: /** * Gets the description string. ...
- Ubuntu下安装Google浏览器
和其他软件一样,比较常用的安装方法. 1.下载deb包对于谷歌Chrome32位版本,使用如下链接:wget https://dl.google.com/linux/direct/google-chr ...
- ado.net介绍
System.Data:DataTable,DataSet,DataRow,DataColumn,DataRelation,Constraint System.Data.Common(各种数据访问类的 ...
- 雷林鹏分享:C# 基本语法
C# 基本语法 C# 是一种面向对象的编程语言.在面向对象的程序设计方法中,程序由各种相互交互的对象组成.相同种类的对象通常具有相同的类型,或者说,是在相同的 class 中. 例如,以 Rectan ...
- 搭建智能合约开发环境Remix IDE及使用
目前开发智能的IDE, 首推还是Remix, 而Remix官网, 总是由于各种各样的(网络)原因无法使用,本文就来介绍一下如何在本地搭建智能合约开发环境remix-ide并介绍Remix的使用. 写在 ...
- 腾讯tOS死亡或注定,为何国内无自主ROM?
http://tech.sina.com.cn/roll/2017-06-26/doc-ifyhmtrw4006354.shtml 腾讯OS死亡或注定,为何国内无自主ROM? 2017年06月26日 ...