在我的应用程序中,我有一个servlet,在web.xml文件中定义如下:
<servlet>
<display-name>Notification Servlet</display-name>
<servlet-name>NotificationServlet</servlet-name>
<servlet-class>com.XXX.servlet.NotificationServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>NotificationServlet</servlet-name>
<url-pattern>/notification/*</url-pattern>
</servlet-mapping>
在迁移到使用Tomcat 7之后,我想要使用@WebServlet
注释来完成工作。
以下是我的做法:
@WebServlet( name="NotificationServlet", displayName="Notification Servlet", urlPatterns = {"/notification"}, loadOnStartup=1)
public class NotificationServlet extends HttpServlet {
它不起作用。 请问有人能告诉我做错了什么吗?