javax.servlet无法解析为类型 [英] javax.servlet cannot be resolved to a type

查看:432
本文介绍了javax.servlet无法解析为类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,当我将Tomcat服务器添加到eclipse和一个servlet项目中时,它不会添加适当的jar,而且我收到错误javax.servlet无法解析为类型

For some reason when I add my Tomcat server to eclipse and a project for servlets it isn't adding the appropriate jars and I'm getting the error "javax.servlet cannot be resolved to a type"

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

Here's my build path settings, as you can see there's no .jars under my Tomcat server:

这是我的tomcat服务器设置:

Here are my tomcat server settings:

这里是错误:

推荐答案

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

Please try below settings, this should work.

项目属性(右键单击项目 - >属性),在Java构建路径中,添加库服务器运行时。添加它将添加 servlet-api.jar 到项目依赖关系。

In Project Properties (Right Click on Project -> Properties), in Java Build Path, add Library "Server Runtime". Adding this will add servlet-api.jar to project dependencies.

选择您的项目→然后点击项目菜单栏顶部转到属性→点击目标运行时间→现在您必须选择服务器旁边的复选框,您正在使用它来运行当前项目→单击应用→然后单击确定按钮

select your project → then click on project menu bar on topgoto to properties → click on Targeted Runtimes → now you must select a check box next to the server you are using to run current project → click Apply → then click OK button

这篇关于javax.servlet无法解析为类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆