代码之家  ›  专栏  ›  技术社区  ›  Greenhorn

< c>导入>标签

  •  4
  • Greenhorn  · 技术社区  · 16 年前

    我正在尝试使用import tag url属性从文件的header.jsp导入文件,但我得到运行时错误--java.io.filenotfoundexception: http://localhost:8081/latest/header.jsp

    导入的文件和同一Web应用程序中的导入文件(最新)。

    导入文件的代码为:

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <html><body>
    <c:import url="http://localhost:8081/latest/header.jsp" charEncoding="UTF-8" />     
    <em>Web services Support Group.</em><br><br>
    </body></html>
    

    导入文件的代码为:

    <em><strong>${param.name}</strong></em><br>
    
    2 回复  |  直到 16 年前
        1
  •  10
  •   skaffman    16 年前

    如果它们在同一个webapp中,则不需要完整的url,只需要相对于webapp根目录的uri:

    <c:import url="/header.jsp" charEncoding="UTF-8" />  
    
        2
  •  0
  •   emas    16 年前

    可能您使用了错误的路径,文件header.jsp在哪里?它在一个名为“最新”的目录中吗?或者“最新”是应用程序的上下文路径?

    斯卡夫曼是对的,你不需要完整的URL,只需要相对于web应用根目录的URL。