简体   繁体   English

在我的jsp页面上包含jsp文件时出错

[英]Error when including jsp files on my jsp page

I am trying to include 2 JSP files in my JSP page. 我试图在我的JSP页面中包含2个JSP文件。 My main page is called temp.jsp - this is in a subfolder in my web project called tempFolder. 我的主页称为temp.jsp,它位于我的Web项目tempFolder的子文件夹中。 I am trying to include a file in the main project folder (called invalidcqs.jsp) and a file (called env_status_report.jsp) in a sub folder (envmon) of the main project folder. 我试图在主项目文件夹中包含一个文件(称为invalidcqs.jsp),并在主项目文件夹的子文件夹(envmon)中包含一个文件(称为env_status_report.jsp)。

the code in my temp.jsp file is: 我的temp.jsp文件中的代码是:

<html>
  <head>
    <title>Screen1 using includes</title>
    <meta http-equiv="refresh" content="10"/>
  </head>
  <body style="background-color:#E6E6FA">
  <%@ include file="../envmon/env_status_report.jsp" %>
    <br><hr><br>
    <%@ include file="../invalidcqs.jsp" %>
  </body>
</html

The second include <%@ include file="../invalidcqs.jsp" %> works fine but the first one <%@ include file="/../envmon/env_status_report.jsp" %> shows an error in Eclipse. 第二个include <%@ include file="../invalidcqs.jsp" %>工作正常,但第一个<%@ include file="/../envmon/env_status_report.jsp" %>显示Eclipse中的错误。

The text of the error is: 错误文本为:

 Multiple annotations found at this line: - Syntax error on token "else", delete this token - Syntax error, insert "Finally" to complete TryStatement - Syntax error on token "else", delete this token 

Does anyone know why Eclipse doesn't like this? 有谁知道为什么Eclipse不喜欢这样?

Usually I don't care much about Eclipse reporting errors on jsp pages, specially when using the <%@ include> directive. 通常,我不太关心jsp页面上的Eclipse报告错误,特别是在使用<%@ include>指令时。 For instance, if you declare a scriptlet variable in your main page and use it in the included page, Eclipse will complain about it not being declared while in the included page, but it will work all right at runtime. 例如,如果您在主页中声明scriptlet变量并在包含的页面中使用它,则Eclipse将抱怨在包含的页面中未声明它,但是它将在运行时正常工作。

This error is possibly coming out of the included jsp, so I'd start looking for this error inside it. 该错误可能是从所包含的jsp中发出的,因此我将开始在其中查找此错误。

您也可以尝试以EL方式包含页面: <jsp:include page="/WEB-INF/pages/received.shtml" />也许会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM