# 14.3　小结

方法级别的安全性是 Spring Security Web 级别安全性的一个重要补充，我们曾在第 9 章讨论过 Web 安全性。对于非 Web 应用来说，方法级别的安全性则是最前沿的防护。对于 Web 应用来讲，基于安全规则所声明的方法级别安全性能够保护 Web 请求。

在本章中，我们看到了六个可以在方法上声明安全性限制的注解。对于简单场景来说，面向权限的注解，包括 Spring Security 的 @Secured 以及基于标准的 @RolesAllowed 都很便利。当安全规则更为复杂的时候，组合使用 @PreAuthorize、@PostAuthorize 以及 SpEL 能够发挥更强大的威力。我们还看到通过为 @PreFilter 和 @PostFilter 提供 SpEL 表达式，过滤方法的输入和输出。

最后，我们还看到了让安全规则更加易于维护、测试和调试的方法， 那就是自定义表达式计算器，它能够用在 SpEL 表达式的 hasPermission() 函数中。

从下一章开始，我们将会转移方向，从使用 Spring 开发后端应用程序转向与其他应用集成。在接下来的几章中，我们将会看到各种集成技术，包括远程服务、异步消息、REST 甚至还有发送 E-mail。在下一章我们将会探讨第一项集成技术，也就是使用 Spring 远程服务。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://potoyang.gitbook.io/spring-in-action-v4/untitled-8/untitled.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
