问题
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 top → goto 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