> For the complete documentation index, see [llms.txt](https://potoyang.gitbook.io/spring-in-action-v4/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://potoyang.gitbook.io/spring-in-action-v4/untitled-3/untitled-1.md).

# 9.5　保护视图

当为浏览器渲染 HTML 内容时，你可能希望视图中能够反映安全限制和相关的信息。一个简单的样例就是渲染用户的基本信息（比如显示 “您已经以……身份登录”）。或者你想根据用户被授予了什么权限，有条件地渲染特定的视图元素。

在第 6 章，我们看到了在 Spring MVC 应用中渲染视图的两个最重要的可选方案：JSP 和 Thymeleaf。不管你使用哪种方案，都有办法在视图上实现安全性。Spring Security 本身提供了一个 JSP 标签库，而 Thymeleaf 通过特定的方言实现了与 Spring Security 的集成。

让我们看一下如何将 Spring Security 用到视图中，就从 Spring Security 的 JSP 标签库开始吧。
