Setting web.xml and context-param listeners with guice servlet

I am working on a web project using guice and guice servlet. I have already configured both the filter and the listener.

With this setting, I can emulate the filters and web.xml servlets in the servlet module using the serve (...) and filter (...) methods.

Now the question is:

On the guice surfing page, they claim that web.xml is no longer needed, but I was unable to figure out how:

register listlisteners (listener-tag in web.xml) and

Add context-param (I can configure init-param you)

Is this possible with the guice servlet?

+4
source share
1 answer

I do not know about Listeners, but it is very simple to manage the servlet context. In your ServletModule.configureServlets ():

getServletContext().setAttribute("productionMode", "true"); 
0
source

Source: https://habr.com/ru/post/1433417/


All Articles