添加“spring-security-taglibs”后jsp中仍然报错:找不到spring security标签的标签库描述符
Posted
技术标签:
【中文标题】添加“spring-security-taglibs”后jsp中仍然报错:找不到spring security标签的标签库描述符【英文标题】:After adding "spring-security-taglibs" Still getting error in jsp: Can not find the tag library descriptor for spring security tag 【发布时间】:2015-12-02 20:21:32 【问题描述】:最初我在添加标签库“http://www.springframework.org/security/tags”后在我的 jsp 中遇到错误,然后我用谷歌搜索发现 spring-security-taglibs jar 丢失了,然后我添加了 jar/ pom.xml 文件中的依赖项。但我仍然遇到同样的错误。任何想法发生了什么。
jsp代码,
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#" style="margin-bottom: 12px"> <img src="$pageContext.servletContext.contextPath/resources/images/bluestar-logo.jpg" class="img-responsive" ></a>
<div style="margin-left:700px">
<h3>Decision Support System for VRF</h3>
</div>
</div>
<!-- <security:authorize ifAnyGranted="ROLE_USER"> -->
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-log-out" style="color:#fff"></span></a></li>
</ul>
</div>
<!-- </security:authorize> -->
</div>
</nav>
在 jsp 中,在这一行我收到错误 任何帮助将不胜感激。
【问题讨论】:
请分享错误描述 springframework.org/security/tags" %> 在这一行我收到错误,因为“找不到“springframework.org/security/tags”的标签库描述符” 可以分享一下你的jsp代码吗 @SaurabhJhunjhunwala,我添加了有问题的jsp代码。 【参考方案1】:这个问题在我想之前已经回答过了,下面是解决方案 Spring Security, JSP Tag Lib Error
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
works for me, with these
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>$spring.security.version</version>
<scope>$defaultScope</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>$spring.security.version</version>
<scope>$defaultScope</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>$spring.security.version</version>
<scope>$defaultScope</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>$spring.security.version</version>
<scope>$defaultScope</scope>
</dependency>
where spring.security.version = 3.1.4.RELEASE.
And make sure you have included the correct jst jar.
【讨论】:
我在 pom 中有所有这些依赖项,但仍然出现错误。 你检查过 spring.security.version = 3.1.4.RELEASE。 我使用的是spring security 4.0.1.RELEASE版本。 试试 spring.security.version = 3.1.4.RELEASE【参考方案2】:对于 Spring MVC,我通过添加来修复它
spring-security-taglibs.jar
文件到 lib 文件夹中。确保您使用与其他安全 jar 相同的 版本
【讨论】:
以上是关于添加“spring-security-taglibs”后jsp中仍然报错:找不到spring security标签的标签库描述符的主要内容,如果未能解决你的问题,请参考以下文章