小编Die*_*ves的帖子

在JAVA中使用注释启动时加载

我有这个代码,

@WebServlet(value="/initializeResources", loadOnStartup=1)
public class InitializeResources extends HttpServlet {

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      System.out.println("HEREEEE");
  }

}
Run Code Online (Sandbox Code Playgroud)

但是,当Web应用程序启动时,servlet无法启动.

如何在Servlet Annotation上启动加载?

我的Servlet API是3.0,我使用Tomcat 7

java tomcat annotations servlets

13
推荐指数
2
解决办法
2万
查看次数

标签 统计

annotations ×1

java ×1

servlets ×1

tomcat ×1