【问题标题】:Not able to include jsp file in other jsp无法在其他jsp中包含jsp文件
【发布时间】:2015-05-28 10:31:33
【问题描述】:

在我的本地主机中它正在工作。但在我的网站 www.step2java.com 中,Java Core 链接不起作用。

当我把 menu.jsp 放在 jsp 文件夹和 nav_home.jsp 放在 navigation-left 文件夹之外它正在工作。

我想知道它在我的本地主机中是如何工作的

您可以访问step2java.com以获取有关问题的更多信息

web.xml

 <web-app>
  <display-name>Archetype Created Web Application</display-name>

  <welcome-file-list>
  <welcome-file>/index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

索引.jsp

<%@include file="/jsp/menu.jsp" %>
<%@include file="/navigation-left/nav_home.jsp" %>
<%@include file="/containerPage/container_Home.jsp" %>
<div class="navigation-right"> </div>

menu.jsp

<link href="<%=request.getContextPath() %>/css/style.css"
            rel="stylesheet" type="text/css" />
 <script  src="<%=request.getContextPath() %>/js/js_library/jquery-1.10.2.js"></script>
 <script  src="<%=request.getContextPath() %>/js/js_library/jquery-1.3.2.min.js"></script>
  <script  src="<%=request.getContextPath() %>/js/navigation.js"></script>

<body>
<div id="header"><div class="container">
<div id="header-logo"> <a title="step2java.com" href="#"><div ><img  style="border: 0 none;height: auto;max-width: 34%;vertical-align: middle;"alt="" src="<%=request.getContextPath() %>/images/logo.jpg" ></div> </a></div>
<h1 style="margin-top: 43px;">Step2Java</h1>
</div></div>
<div id="menu"><div class="container">
<ul><li class="menu-allround"> <a href="<%=request.getContextPath()%>">Home</a></li><li class="menu-allround"> <a href="<%=request.getContextPath()%>/jsp/javaHome.jsp">Java Core</a></li><li class="menu-allround"> <a href="#">Spring</a></li><li class="menu-topround"> <a href="#">Hibernate</a><div class="dropdown" id="hibernate-menu"><div class="tut-title">Hibernate Tutorials</div><div class="dropdown-item"> <div>1. <a href="#">Hibernate Core</a></div></div></div></li><li class="menu-topround"> <a href="#">Others</a><div class="dropdown" id="misc-menu"><div class="dropdown-item"><ol><li><a href="#">Java MongoDB</a></li><li><a href="#">jUnit</a></li><li><a href="#">jQuery</a></li></ol></div></div></li></ul>

</div></div>

</body>

【问题讨论】:

  • 当我单击链接时,我收到“正确”错误 - org.apache.jasper.JasperException: javax.servlet.ServletException: File [/navigation-left/nav_javaCore.jsp] not found -你的问题是什么?您是否从本地 Web 服务器(例如 Tomcat\work 目录)中删除了任何临时数据并重新启动服务器 - 仍然工作?
  • 请上传包含您的文件结构的图片。
  • 点击javaHome后会跳转到javaHome.jsp

标签: java jsp


【解决方案1】:

在您的index.jsp 页面中使用dynamic include

<jsp:include page="jsp/menu.jsp" />
<jsp:include page="navigation-left/nav_home.jsp" />
<jsp:include page="containerPage/container_Home.jsp" />

【讨论】:

  • 我正在使用 jsp:include javahome.jsp 在 index.jsp 中使用 jsp:include 有什么好处
  • @SoumyaRanjan 请参阅stackoverflow.com/questions/14580120/… 了解区别。
  • @SoumyaRanjan 你的战争结构是什么?
猜你喜欢
  • 2015-02-23
  • 1970-01-01
  • 2023-03-12
  • 2017-10-25
  • 2016-02-19
  • 1970-01-01
  • 2016-08-12
  • 2014-02-08
  • 2019-05-18
相关资源
最近更新 更多