使用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 ...
随机推荐
- _itemmod_rate_stone
`entry`几率宝石物品ID `type` 1--合成对应_itemmod_exchange_item 2--强化对应_itemmod_exchange_item 3-附魔(除itemMask = ...
- 【BZOJ】3573: [Hnoi2014]米特运输
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3573 屁话一堆,就是说: 1.一棵树中的每个点的每个儿子的权值之和要等于这个点的权值 2. ...
- 关于System.in如何执行的问题
import java.io.IOException; public class Test1 { public static void main(String[] args) throws IOExc ...
- Selenium IDE使用
基于版本Selenium IDE 3.2.2(注:该工具不常用,可以使用定位元素是否存在) Selenium IDE可以录制也很方便,当然录下来的经常回放不成功,需要自己调试就是了.它是只针对Web页 ...
- nodejs项目安装ant design
1.确保安装好nodejs $ node --version v10.4.1 2.确保npm $ npm -v 6.1.0 3.安装 $ sudo npm install antd-init -g / ...
- ORACLE的rownum用法讲解
如果选择踏足,终有一天你会爱上这条路. 今天讲讲ORACLE中关于ROWNUM的用法: 一.简单介绍一下ROWNUM是什么,可以用来干什么. 答:ROWNUM是一个序列,会根据sql语句自动给你加上一 ...
- 异常处理.VC++
ZC:个人这样 理解 C++的异常处理: ZC: (1).C++标准异常处理,try{}catch{} 抛异常:throw() [ 据说是包装的Windows函数RaiseException() ] ...
- [原][osg]osgconv浅析
查看osgconv.cpp main函数在533行 osg::ArgumentParser arguments(&argc,argv); //........一堆功能不管,先看一下文件读写 F ...
- ts问题处理(2): 'Promise' only refers to a type, but is being used as a value here.
error TS2585: 'Promise' only refers to a type, but is being used as a value here. Do you need to cha ...
- composer修改中文镜像
composer config -g repo.packagist composer https://packagist.phpcomposer.com