org.apache.jasper.JasperException:属性前缀[fn]没有对应任何导入的标签库

org.apache.jasper.JasperException: The attribute prefix [fn] does not correspond to any imported tag library

我正在尝试使用 IntelliJIDEA 14.1.4 部署 运行 Hello World 应用程序 在 Tomcat 8.0.14(Tomcat Server -> Local) 上。该项目是使用 maven-archetype-webapp 创建的,后来被导入 通过指定 pom.xml.

的路径到 IDE

一切正常,如 servlets 标签信息中所述,但是当我删除以下行时:

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

并将其添加到我的include.jsp中,我遇到了一个:

org.apache.jasper.JasperException: /WEB-INF/jsp/hello.jsp (line: 18, column: 42) The attribute prefix [fn] does not correspond to any imported tag library

项目结构:

include.jsp

<%-- 'header' file that will be included in every JSP page ensuring the same definitions are included in all our JSPs. --%>
<%@ page session="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

index.jsp:

<%@ include file="/WEB-INF/jsp/include.jsp" %>
<c:redirect url="/WEB-INF/jsp/hello.jsp"/>

hello.jsp:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Application Home</title>
  <style>.error {
    color: red;
  }
  .success {
    color: green;
  }</style>
</head>
<body>
<form action="hello" method="post">
  <h1>Hello</h1>

  <p>
    <label for="name">What's your name?</label>
    <input id="name" name="name" value="${fn:escapeXml(param.name)}">
    <span class="error">${messages.name}</span>
  </p>

  <p>
    <label for="age">What's your age?</label>
    <input id="age" name="age" value="${fn:escapeXml(param.age)}">
    <span class="error">${messages.age}</span>
  </p>

  <p>
    <input type="submit">
    <span class="success">${messages.success}</span>
  </p>
</form>
</body>
</html>

问题:

只添加一次该行是个坏主意吗(include.jsp)以便我可以在需要的地方使用它而不是在每个 JSP 中添加它或者是由于某些原因导致错误还有什么我想念的?

看起来很愚蠢,我错过了 hello.jsp 中导致异常的 include 语句。发布答案是因为我想在此保留此信息以供将来参考。

hello.jsp

中缺少语句
<%@ include file="/WEB-INF/jsp/include.jsp" %>

hello.jsp:

<%@ include file="/WEB-INF/jsp/include.jsp" %>
<!DOCTYPE html>
....
</body>
</html>