【问题标题】:Unknown tag (c:if) warning in jspjsp中的未知标记(c:if)警告
【发布时间】:2016-12-07 22:49:33
【问题描述】:
    <%@ 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>  

在此代码中收到未知标记警告。我已在 WEB-INF/lib 目录中包含 jstl jar 文件。因为突出显示的代码块仅显示此警告。我找不到我的错误。请帮助。

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>

【问题讨论】:

  • 发布pom.xml 依赖项。
  • 添加了带有原始帖子的 pom 条目。 @tarashypka
  • 所以当您忽略 Eclipse 的警告并运行它时它工作正常吗?因此这是一个 Eclipse 问题而不是 JSP/JSTL 问题?

标签: jsp jstl jsp-tags taglib


【解决方案1】:

这似乎是 Eclipse 的问题。我尝试重新启动eclipse,但没有帮助。

最后,我只是忽略了 Eclipse 的“未知标签”警告并重新启用它。现在一切看起来都很好。现在只显示真正的警告。

Eclipse-->Windows-->首选项-->Web-->HTML 文件-->验证

【讨论】:

    猜你喜欢
    • 2016-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-15
    • 2014-08-26
    • 2018-01-26
    • 1970-01-01
    相关资源
    最近更新 更多