gpt4 book ai didi

java - 尝试将文件路径包含到索引页时出现问题

转载 作者:行者123 更新时间:2023-12-02 00:42:41 25 4
gpt4 key购买 nike

当我包含时 <%@include file="../WEB-INF/jspf/Header.jspf"%>

header 内的图像无法访问,CSS 文件也未正确链接!!,这是我的文件的层次结构

enter image description here

在 StudentIndex.jsp 中我这样做

<link type="text/css" rel="stylesheet" href="../css/StudentStyle.css"/>
<%@include file="../WEB-INF/jspf/Header.jspf" %>

和 Header.jspf

<link href="../css/Style.css" type="text/css" rel="stylesheet"/>
<img src="../images/iuglogo.gif" alt="IUG logo" id="IUGlogoStyle"/>

编辑

当我运行 StudentIndex.jsp 时,所有文件都正确运行

http://localhost:8080/OnlineQuerySystemNew/Student/StudentIndex.jsp

但是当请求从 servlet 转发到 StudentIndex 页面时,没有附加任何图像和 css 文件

http://localhost:8080/OnlineQuerySystemNew/StudentManagementServlet?param=activationOptions

最佳答案

  • 获取JSTL
  • 像这样在 jsp 页面中包含 taglib -

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

  • 使用url tag摆脱你的痛苦。像这样 -
<link rel="stylesheet" type="text/css" href='<c:url value="/css/Style.css" />' />
<img src='<c:url value="/images/iuglogo.gif" />' alt="IUG logo" id="IUGlogoStyle"/>

关于java - 尝试将文件路径包含到索引页时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5876491/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com