eclipse 爪哇项目。JspWriter 的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7001936/
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
Java project. Problem with JspWriter
提问by bobetko
I got some old JSP web project at work that I am trying to import into eclipse. My experience with java and eclipse is far from great.
我有一些旧的 JSP Web 项目正在工作,我正试图将其导入 Eclipse。我在 java 和 eclipse 方面的经验远非很好。
In one of the jsp files I am having error:
The import javax.servlet.jsp.JspWriter cannot be resolved
在其中一个 jsp 文件中,我遇到错误:
无法解析导入 javax.servlet.jsp.JspWriter
The code:
编码:
<%@ page import="org.apache.axiom.om.OMAbstractFactory,
org.apache.axiom.om.OMElement,
org.apache.axiom.om.OMFactory,
org.apache.axiom.om.OMNamespace,
org.apache.axis2.AxisFault,
org.apache.axis2.Constants,
org.apache.axis2.addressing.EndpointReference,
org.apache.axis2.client.Options,
org.apache.axis2.client.ServiceClient,
org.apache.axis2.context.ConfigurationContext,
org.apache.axis2.context.ConfigurationContextFactory,
javax.servlet.ServletContext,
javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse,
javax.servlet.jsp.JspWriter, <- Problem is HERE
javax.xml.parsers.SAXParser,
javax.xml.parsers.SAXParserFactory"
session="false" %>
And, of course, on any other place where I have reference to JspWriter I get same error.
而且,当然,在我引用 JspWriter 的任何其他地方,我都会遇到同样的错误。
I looked at Java Build Path and I have following:
1) servlet-api.jar - C:\Program Files...
2) Ear Libraries
3) JRE System Library (jdk1.6.0_25)
4) Web App Libraries
我查看了 Java Build Path,我有以下内容:
1) servlet-api.jar - C:\Program Files...
2) Ear Libraries
3) JRE System Library (jdk1.6.0_25)
4) Web App Libraries
I used to have one item for Apache Tomcat 6.0 library which was unbound so I removed it. I tried to add it but couldn't. When I click Add Library > Server Runtime I get new window says: "Select a runtime to add to the classpath", but there is nothing to select.
我曾经有一项用于 Apache Tomcat 6.0 库的未绑定项,因此我将其删除。我试图添加它但不能。当我单击“添加库”>“服务器运行时”时,出现新窗口显示:“选择要添加到类路径的运行时”,但没有任何选择。
I have installed: Eclipse Java EE IDE for Web Developers, Apache Tomcat installed (6.0), latest version of Ant and Windows 7 64bit.
我已经安装了:Eclipse Java EE IDE for Web Developers,安装了 Apache Tomcat (6.0),最新版本的 Ant 和 Windows 7 64bit。
Any ideas?
有任何想法吗?
Thanks.
谢谢。
回答by BalusC
The import javax.servlet.jsp.JspWriter cannot be resolved
导入 javax.servlet.jsp.JspWriter 无法解析
In case of Tomcat, it's part of jsp-api.jar
file. However, do notmanually add this file to the buildpath like as you did for servlet-api.jar
, that would not be the right way! It would make your webapp unportableto other target runtimes (read: servletcontainers). I.e. your webapp would be compatible with Tomcat 6.0 only, but not with other container makes/versions like Tomcat 7, Glassfish, JBoss AS, etc.
在 Tomcat 的情况下,它是jsp-api.jar
文件的一部分。不过,千万不能手动将此文件添加到构建路径类似像你一样的servlet-api.jar
,那会不会是正道!它会使您的 web 应用程序无法移植到其他目标运行时(阅读:servletcontainers)。即您的 web 应用程序将仅与 Tomcat 6.0 兼容,但不与其他容器制造商/版本(如 Tomcat 7、Glassfish、JBoss AS 等)兼容。
I looked at Java Build Path and I have following:
1) servlet-api.jar - C:\Program Files...
我查看了 Java Build Path,我有以下内容:
1) servlet-api.jar - C:\Program Files...
Remove this one. It'll only collide with any target runtime which you're going to configure soon.
去掉这个。它只会与您即将配置的任何目标运行时发生冲突。
I used to have one item for Apache Tomcat 6.0 library which was unbound so I removed it. I tried to add it but couldn't. When I click Add Library > Server Runtime I get new window says: "Select a runtime to add to the classpath", but there is nothing to select.
我曾经有一项用于 Apache Tomcat 6.0 库的未绑定项,因此我将其删除。我试图添加它但不能。当我单击“添加库”>“服务器运行时”时,出现新窗口显示:“选择要添加到类路径的运行时”,但没有任何选择。
Go to Serversview in Eclipse. Rightclick it and choose New. Pick the appropriate servletcontainer make and version and walk through the wizard. Now you've a target runtime in Eclipse.
转到Eclipse 中的服务器视图。右键单击它并选择New。选择适当的 servletcontainer 制造商和版本并完成向导。现在您在 Eclipse 中有一个目标运行时。
Then, in the project's properties, go to Targeted Runtimesand select the server in there. Nothing else needs to be done. Eclipse will take care of the remaining magic.
然后,在项目的属性中,转到Targeted Runtimes并选择其中的服务器。没有其他事情需要做。Eclipse 会处理剩下的魔法。
See also:
也可以看看:
回答by Vineet Reynolds
javax.servlet.jsp.JspWriter
will not present in servlet-api.jar
of your Tomcat distribution. Rather, it is usually present in the jsp-api.jar
file.
javax.servlet.jsp.JspWriter
不会出现在servlet-api.jar
您的 Tomcat 发行版中。相反,它通常存在于jsp-api.jar
文件中。
You should rebind the Apache Tomcat 6 Server Runtime, back into your project's classpath, so that all the JARs provided by Tomcat 6 are made available once again. An unbound Tomcat 6 Server Runtime serves no purpose other than to inform you that you've copied an Eclipse project whose classpath entries were or might have been valid in the original Eclipse workspace.
您应该将 Apache Tomcat 6 Server Runtime 重新绑定到项目的类路径中,以便 Tomcat 6 提供的所有 JAR 再次可用。未绑定的 Tomcat 6 Server Runtime 仅用于通知您您复制了一个 Eclipse 项目,该项目的类路径条目在原始 Eclipse 工作区中有效或可能有效。
To reintroduce the Apache Tomcat 6 Server into your project's classpath, first define the Server Runtime in Eclipse, using your existing Tomcat 6 installation. Later, add the Server Runtime as a library in your project's build path.
要将 Apache Tomcat 6 服务器重新引入项目的类路径,首先在 Eclipse 中定义服务器运行时,使用现有的 Tomcat 6 安装。稍后,将服务器运行时作为库添加到项目的构建路径中。
回答by FUD
As the error is only with "javax.servlet.jsp.JspWriter" i would have first gone and checked wether this class actually exists in the jar you have put in the project classpath. Also it is not a bad idea to create a new dynamic web project in Eclipse Java EE with required facets and just import the source files.
由于错误仅与“javax.servlet.jsp.JspWriter”有关,因此我首先会检查此类是否确实存在于您已放入项目类路径中的 jar 中。此外,在 Eclipse Java EE 中创建一个具有所需方面的新动态 Web 项目并只导入源文件也不是一个坏主意。