如果你需要Spring jsp页面授权,请按照以下步骤,
第一步:需要在网络安全文件中激活网络授权
在 http 标记中使用-expressions="true" 在安全 xml 文件中
例如:<http .... use-expressions="true">
然后你配置 pom.xml 以便下载 spring
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
步骤 2。然后在你需要的jsp页面中添加标签库
例如:
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
Step3:然后检查jsp页面中的hasRole
例如:
<security:authorize access="hasRole('ROLE_USER')">
This text is only visible to a user
<br/>
</security:authorize>
<security:authorize access="hasRole('ROLE_ADMIN')">
This text is only visible to an admin
<br/>
</security:authorize>
在那个地方 userRole 区分大小写
您还可以提供基于角色的完整页面访问权限.. 使用以下示例代码
<intercept-url pattern="/user/**" access="hasRole('ROLE_USER')" />
此拦截允许该页面中的角色用户。
根据您的问题,您应该验证网络安全文件必须有use-expression="true"
如果正确请确认角色名。因为区分大小写