简体   繁体   English

如何在 Jersey Provider 中获取 ServeletConfig?

[英]How to get ServeletConfig in Jersey Provider?

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.所以我有一个 Jersey REST 服务,我需要访问一个 ServletConfig 以便我可以从 web.xml 中提取一个参数。 I can use @Context to wire one in but I don't think it will get me the params I need.我可以使用 @Context 来连接一个,但我认为它不会让我得到我需要的参数。 Only the ones in the ServletContext.只有 ServletContext 中的那些。

Any ideas?有任何想法吗? I'm new to Jersey and this Provider isn't a Servelet.我是泽西岛的新手,这个 Provider 不是 Servelet。 Perhaps I should start with trying to retrieve the servelet?也许我应该从尝试检索小服务开始?

@Context: annotation can be used to inject the following classes @Context:注解可用于注入以下类

  1. HttpServletRequest HttpServletRequest

  2. HttpServletResponse HttpServletResponse

  3. ServletContext服务端上下文

  4. ServletConfig Servlet配置

  5. WebConfig.网络配置。

onto a root resource, provider and Application classes.到根资源、提供程序和应用程序类。

Java Doc of Servlet Container Servlet 容器的 Java 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用javax动态servlet注册配置多个Jersey提供程序包 - How to configure multiple Jersey provider packages using javax dynamic servlet registration 如何在泽西岛设置AbstractBinder - How to set an AbstractBinder in Jersey 在Jersey中无法获取POST请求的有效负载 - Can't get the payload of a POST Request in Jersey 如何检索Jersey ContainerRequest属性? - How to retrieve Jersey ContainerRequest properties? 如何使用Jersey和Java EE 5检索ServletRequest - How to retrieve ServletRequest using Jersey and Java EE 5 关于 `jersey.config.server.provider.scanning.recursive` 参数,我应该考虑什么? - What should I take into consideration regarding the `jersey.config.server.provider.scanning.recursive` parameter? 迁移到泽西2.x现在我得到servlet容器异常 - Migrated to jersey 2.x and now I get servlet container exception 在Jetty / Jersey中,我对自定义身份验证标头使用了过滤器,以映射到用户角色。 如何使用ReSTlet完成此操作? - In Jetty/Jersey I use a filter for custom auth headers to get mapped to user roles. How do I accomplish this using ReSTlet? 如何将 servlet 请求分派到 Jersey 资源方法 - How to dispatch servlet requests to Jersey resource methods 如何将 Swagger 与 Maven + Java + Jersey + Tomcat 集成 - How to integrate Swagger with Maven + Java + Jersey +Tomcat
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM