JSP 和 Eclipse 的验证问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/597516/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Validation problem with JSP and Eclipse
提问by Luke
I have this simple JSP page in Eclipse and the first line in the file is:
我在 Eclipse 中有这个简单的 JSP 页面,文件中的第一行是:
Eclipse however, puts a yellow warning icon before this line with the following tooltip message:
但是,Eclipse 会在此行之前放置一个黄色警告图标,并带有以下工具提示消息:
Multiple annotations found at this line:
- Line breakpoint:index.jsp [line: 1]
- Tag (jsp:directive.page) should be an empty-element tag.
在这一行找到多个注释:
- Line breakpoint:index.jsp [line: 1]
- Tag (jsp:directive.page) 应该是一个空元素标签。
Does anyone know why this is?
有人知道为什么是这样吗?
UPDATE:
更新:
This is my full source script. This is basically the template that Eclipse generates for me when I create a new JSP file based on the XHTML template. I only slightly modified the content to make it do something 'use full'.
这是我的完整源脚本。这基本上是我在基于 XHTML 模板创建新 JSP 文件时 Eclipse 为我生成的模板。我只是稍微修改了内容以使其“充分使用”。
I'm using Eclipse 3.4 (eclipse-jee-ganymede-SR1-linux-gtk.tar.gz) on Ubuntu 8.10 with the Geronimo 2.1 plug-in (I don't think that matters though). I had this same problem with every version of Eclipse I've used so far (3.0 and up)
我在 Ubuntu 8.10 上使用 Eclipse 3.4 (eclipse-jee-ganymede-SR1-linux-gtk.tar.gz) 和 Geronimo 2.1 插件(不过我认为这并不重要)。到目前为止,我使用过的每个 Eclipse 版本(3.0 及更高版本)都遇到了同样的问题
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<jsp:useBean id="datetime" class="java.util.Date" />
<html>
<head>
<title>Hello Geronimo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div>
<h1>Hello Apache Geronimo!!!</h1>on ${datetime}
</div>
</body>
</html>
采纳答案by VonC
It's an oddity of the DOM validation that happens in the editor even for JSP files, reported in bug 248963for another situation.
It's expected to be resolved in WTP 3.0.4 & Ganymede SR2.
即使对于 JSP 文件,编辑器中也会发生 DOM 验证的奇怪之处,在错误 248963 中报告了另一种情况。
预计将在 WTP 3.0.4 和 Ganymede SR2 中解决。
So what eclipse and WTP version are you using ?
那么您使用的是什么 eclipse 和 WTP 版本?
Can you check if this is still the case when you add the following line just beneath the initial jsp declaration:
当您在初始 jsp 声明下方添加以下行时,您能否检查是否仍然如此:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
as mentioned in bug 257258(also fixed in WTP 3.0.4 & Ganymede SR2): before WTP3.0.4, this doctype was enough to not showyour warning:
如错误 257258 中所述(也在 WTP 3.0.4 和 Ganymede SR2 中修复):在 WTP3.0.4 之前,此文档类型足以不显示您的警告:
(source: eclipsetotale.com)
(来源:eclipsetotale.com)