包 javax.servlet.annotation 不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24832229/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
package javax.servlet.annotation does not exist
提问by rocky
I have some of the following imports defined like the following as shown in the image below.
我有一些如下定义的导入,如下图所示。
I am wondering, how can I eliminate "package javax.servlet.annotation does not exist"
error. I am currently working on "Java Web" type of project in Netbeans 7.4. .
我想知道,我怎样才能消除"package javax.servlet.annotation does not exist"
错误。我目前正在 Netbeans 7.4 中处理“Java Web”类型的项目。.
Secondly, I believe , the above error is the reason behind my second error related to "WebServlet" which is shown in the image above (line #44).
其次,我相信,上述错误是我第二个与“WebServlet”相关的错误背后的原因,如上图所示(第 44 行)。
Please let me know how to fix this problem.
请让我知道如何解决这个问题。
Read some other posts like this one, but I believe they are not using Netbeans and not sure if I should update tomcat as mentioned in the post. The location of the servlet api jar file is as shown in the image below:
阅读其他一些类似的帖子,但我相信他们没有使用 Netbeans,并且不确定我是否应该按照帖子中提到的那样更新 tomcat。servlet api jar 文件的位置如下图所示:
采纳答案by Braj
WebServlet
is added in servlet-api
version 3.0, so make sure you are using updated version and it's added in the class path of the project.
WebServlet
是在servlet-api
3.0 版中添加的,因此请确保您使用的是更新版本并将其添加到项目的类路径中。
Have a look at servlet-api-2.5 classeswhere WebServlet.class
is not included, it's part of servlet-api-3.x classes
看一看servlet的API-2.5类,其中WebServlet.class
不包括在内,它的一部分的servlet的API-3.X类