javax.servlet无法解析为某种类型

时间:2014-11-24 00:44:41

标签: java eclipse tomcat servlets

出于某种原因,当我将我的Tomcat服务器添加到eclipse和servlet的项目时,它不会添加适当的jar并且我得到错误" javax.servlet无法解析为类型"

这是我的构建路径设置,因为您可以看到我的Tomcat服务器下没有.jars:

enter image description here

以下是我的tomcat服务器设置:

enter image description here

以下是错误:

enter image description here

2 个答案:

答案 0 :(得分:2)

请尝试以下设置,这应该有用。

Project Properties (Right Click on Project -> Properties), in Java Build Path中,添加库“服务器运行时”。添加此项会将servlet-api.jar添加到项目依赖项中。

select your project→然后点击项目menu bar on topgoto to properties→点击Targeted Runtimes→现在您必须select a check box next to the server用于运行当前项目→{ {1}}→然后单击确定按钮

答案 1 :(得分:0)

尝试直接从Apache下载tar / zip,并将您解压缩的位置用作“安装目录”。