How to get ServeletConfig in Jersey Provider?

老子叫甜甜 提交于 2019-12-12 04:44:08

问题


So I have a Jersey REST service and I need to get access to a ServletConfig so that I can pull a param out of the web.xml. I can use @Context to wire one in but I don't think it will get me the params I need. Only the ones in the ServletContext.

Any ideas? I'm new to Jersey and this Provider isn't a Servelet. Perhaps I should start with trying to retrieve the servelet?


回答1:


@Context: annotation can be used to inject the following classes

  1. HttpServletRequest

  2. HttpServletResponse

  3. ServletContext

  4. ServletConfig

  5. WebConfig.

onto a root resource, provider and Application classes.

Java Doc of Servlet Container



来源:https://stackoverflow.com/questions/22265528/how-to-get-serveletconfig-in-jersey-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!