使用时候必须先加上<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>标签库,然后根据需求设置相应的权限(接下一篇文章‘spring整合security’的相关前置配置)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>授权-标签</title>
</head>
<body>
<!--
对应的权限下才会显示,否则掩藏,登录时候只显示查询的角色
-->
<H1>角色管理</H1>
当前登录的用户:<security:authentication property="principal.username"/>
<security:authorize access="hasAnyRole('ROLE_QUERY')">
<a href="#" >添加角色</a>
</security:authorize>
<security:authorize access="hasAnyRole('ROLE_UPDATE')">
<a href="#" >修改角色</a>
</security:authorize>
<security:authorize access="hasAnyRole('ROLE_USER')">
<a href="#" >查询角色</a>
</security:authorize>
<security:authorize access="hasAnyRole('ROLE_DELETE')">
<a href="#" >删除角色</a>
</security:authorize>
</body>
</html>