javax.servlet cannot be resolved to a type

白昼怎懂夜的黑 提交于 2020-01-06 13:57:12

问题


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"

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

Here are my tomcat server settings:

And here are the errors:


回答1:


Please try below settings, this should work.

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




回答2:


Try downloading a tar/zip from Apache directly, and using the location you unpack it into as the "installation directory."



来源:https://stackoverflow.com/questions/27096301/javax-servlet-cannot-be-resolved-to-a-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!