如何从 Restlet 读取上下文参数?
使用Restlet时,如何读取通过web.xml传入的配置参数? 对于 servlet,可以使用 context-param。 如何从 Restlet 中读取上下文参数?
When using Restlets, how can I read configuration parameters passed in through web.xml? With servlets, context-param can be used. How do I read context parameters from within a Restlet?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自邮件列表:
在 web.xml 中:
在 Restlet 的代表方法中,使用:
From the mailing list:
In web.xml:
In a Restlet's represent method, use:
ServerServlet
将来自servletConfig
和servletContext
的所有 init 参数添加到应用程序上下文中。因此,根据您的需要,您可以检查 ServerServlet 的源代码,并以相同的方式读取配置参数,或者只是从您的 Restlet 或 Restlet 的应用程序上下文中获取值。
ServerServlet
adds all the init parameters from both theservletConfig
and from theservletContext
to the application context.So depending on your need, you could either examine the source code for
ServerServlet
, and read the configuration parameters in the same way, or simply obtain the values from your restlet, or your restlet's application's context.