java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?

前端 未结 4 1718
野趣味
野趣味 2021-02-12 14:50

This the file web.xml in WEB-INF





        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-12 15:24

    You have both ContextLoaderServlet and DispatcherServlet set to load-on-startup = 1. That means either one of them could start first, and you need the ContextLoaderServlet to start first, since that's what creates the root WebApplicationContext that your error says is missing. So leave ContextLoaderServlet's load-on-startup at 1, and change the DispatcherServlet's to 2 or higher.

    Actually, it's preferred to use ContextLoaderListener instead of the Servlet unless you're on a really old container where the Listener doesn't work properly.

提交回复
热议问题