且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java项目。 JspWriter的问题

更新时间:2023-12-04 11:48:58


导入javax.servlet .jsp.JspWriter无法解析

如果是Tomcat,它是 jsp-的一部分api.jar 文件。但是,手动将此文件添加到构建路径,就像您对 servlet-api.jar 所做的那样,这不是正确的方法!它会使您的webapp 不可移植到其他目标运行时(读取:servletcontainers)。即您的webapp仅与Tomcat 6.0兼容,但与其他容器品牌/版本(如Tomcat 7,Glassfish,JBoss AS等)不兼容。

In case of Tomcat, it's part of jsp-api.jar file. However, do not manually 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 unportable to 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.


我查看了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.


我曾经为Apache Tomcat 6.0库提供了一个未绑定的项目,所以我将其删除了。我试图添加它但不能。当我单击添加库>服务器运行时我得到一个新窗口说:选择要添加到类路径的运行时,但没有什么可以选择。

转到Eclipse中的 Servers 视图。右键单击它并选择 New 。选择适当的servletcontainer品牌和版本并完成向导。现在你在Eclipse中有一个目标运行时。

Go to Servers view 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.

然后,在项目的属性中,转到 Targeted Runtimes 并在那里选择服务器。没有别的事情需要做。 Eclipse将处理剩余的魔法。

Then, in the project's properties, go to Targeted Runtimes and select the server in there. Nothing else needs to be done. Eclipse will take care of the remaining magic.


  • 如何导入javax.servlet API在我的Eclipse项目中?

  • How do I import the javax.servlet API in my Eclipse project?