ServletContainerInitializer vs ServletContextListener

后端 未结 2 1000
再見小時候
再見小時候 2020-12-07 12:49

I\'m trying to register a servlet using servletContainerInitializer but it doesn\'t seem to work, Maybe it\'s my code (kindly review it), but I came to wonder about the diff

2条回答
  •  猫巷女王i
    2020-12-07 13:16

    Check if you have configured the ServletContainerInitializer propertly. The ServletContainerInitializer class name should be configured inside a file:

    META-INF/services/javax.servlet.ServletContainerInitializer
    

    The file should contain just the class name. For Ex in your case it should look like:

    com.marmoush.javaexamples.nullhaus.servlet.MyInit
    

    The file (META-INF/services/javax.servlet.ServletContainerInitializer) can be bundled in a library JAR in WEB-INF/lib.

    Here is any example which explains.

提交回复
热议问题