【问题标题】:how can i call one jsp page to another jsp page如何将一个jsp页面调用到另一个jsp页面
【发布时间】:2013-02-18 05:32:59
【问题描述】:

您好,我有一个 Jsp 页面,我想在我的另一个 jsp 页面中调用该 jsp 页面。例如我有 includefile.jsp 页面

 <html>
<body>
    <b><font color='red'> Hello World</font></b><br>
    <b><font color='red'> HTML file is included in JSP page<font></b>
</body>
</html>

我有 include.jsp 页面,我想在其中调用第一个 jsp

<html>
<body>
<%@ include file='includedFile.jsp' %>
</body>
</html>

但此代码不起作用。如果有人能帮我解决这个问题,我将不胜感激。

【问题讨论】:

  • 你看过这个stackoverflow.com/questions/9110148/include-another-jsp-file 并且还要确保你给includedFile.jsp 的正确路径的目录结构
  • 是的,我给出了正确的路径。两个jsp都在同一个文件夹中,我不知道它有什么问题,我也看到了堆栈溢出的例子,但我无法让我的代码与那个例子一起工作。
  • 尝试从您的 includedFile.jsp 中删除 和 标签,然后检查
  • 我只是看到了!在问题的开头,你写了文件名includefile.jsp,在代码中,你使用了includedFile.jsp。确保你在文件名中给出正确的名称以及区分大小写
  • 是的,我已经更正了名称,即使我尝试删除 和 标记仍然无法正常工作

标签: jsp jsp-tags jspinclude


【解决方案1】:

在您的 include.jsp 页面中

<html>
<body>
<form action = "includeFile.jsp">
<input type="submit" value="open other jsp">
</form>
</body>
</html>

**确保将两个 JSP 文件放在同一个文件夹中。

【讨论】:

    猜你喜欢
    • 2012-01-30
    • 2013-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多