<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<html>
<head>
<title>Sample Title</title>
<style type="text/css">
body {
background-color: Lightgrey;
}
</style>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Sample Page</h1><br>
<h3>Admin</h3>
<ul class="list-inline">
<li><a href="http://localhost:8080/sample/tab1">Tab 1</a></li>
<li><a href="http://localhost:8080/sample/tab2">Tab 2</a></li>
<li><a href="http://localhost:8080/sample/tab3">Tab 3</a></li>
</ul>
**<c:set var="isAllowed" value="${false}" />
<sec:authorize access="isAuthenticated()">
<sec:authorize access="hasAuthority('PERMISSION_MANAGER')" var="isAllowed" />
</sec:authorize>**
<c:if test="${isAllowed}">
<h3>Manager</h3>
<ul class="list-inline">
<li><a href="http://localhost:8080/sample/tab1/search">Search</a></li>
<li><a href="http://localhost:8080/sample/tab1/add">Add</a></li>
<li><a href="http://localhost:8080/sample/tab1/delete">Delete</a></li>
</ul>
</c:if>
</div>
</body>
</html>
在此代码中收到未知标记警告。我已将 jSTL jar 文件包含在 WEB-INF/lib 目录中。因为突出显示的代码块仅显示此警告。我找不到我的错误。请帮忙。
JSTL 核心和安全标记库包含在 jsp 文件的顶部。
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
并在 maven 依赖项中包含 jSTL jar。但是对于 Eclipse 中的所有 jSTL 标签,我仍然收到警告消息作为 Unknown tag。有人可以帮助我避免 jsp 页面中所有 jSTL 标记的警告吗?
谢谢
更新:
<properties>
<jstl.version>1.2</jstl.version>
<spring-security.version>4.0.3.RELEASE</spring-security.version>
<properties>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${spring-security.version}</version>
</dependency>
最佳答案
看来是 Eclipse 的问题。我尝试重新启动 Eclipse,但没有帮助。
最后,我只是忽略了 Eclipse 的“Unknown tag”警告并重新启用它。现在一切看起来都很好。现在只显示真正的警告。
Eclipse-->Windows-->首选项-->Web-->HTML文件-->验证
关于jsp - 未知标签 (c :if) warning in jsp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38722856/