更改KARAF / OSGI蓝图Web应用程序的基本URL /上下文路径
我有一个Web应用程序,它在我的OSGI-INF/blueprint/web-blueprint.xml中使用PAX Web中配置了几个servlet。 Web应用程序由两页 /loginpage.html和 /dashboard.html组成,但是后者支持几种视图,每种视图都与自己的Angular Controller和相关的后端Servlet相关联。
我可以通过URL https://< ip>:< port>/loginpage.html
and https:// https:// port; ip> ip> /dashboard.html
。访问https://&< ip>:< port>/
重定向到https://< ip>:< port>/loginpage.html
。
如果我们调用https://< ip>:< port>/
基本URL,我现在想将此基本URL更改为https:https:https:// ip&lt> ip> ;:< port>/test/
,以便
- 在下面可用
https://< ip>:< port>/test/loginpage.html
andhttps:// https:// port> ip>:< port< /代码>分别
https://&< ip>:< port>/test
简单地重定向到https://< ip>: >。
因为文件etc/org.ops4j.pax.web.cfg
将etc/jetty.xml
指定为其配置文件,所以我假设我可以在Jetty中配置它。 XML。当前的Jetty.xml是标准的。码头文档说,可以通过添加以下内容来设置上下文路径:
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/test</Set>
</Configure>
但是,将上述简单地添加到标准码头conf文件的末尾,原因是我的网页根本无法访问。我找不到任何进一步的文档或示例我如何获得这项工作...
我非常感谢任何帮助!
I have a Web app with several servlets configured in my OSGI-INF/blueprint/web-blueprint.xml using pax web. The web app consists of two pages /LoginPage.html and /Dashboard.html, but the latter supports several views, each associated with an own angular controller and related backend servlet.
I can reach the two pages by the URLs https://<ip>:<port>/LoginPage.html
and https://<ip>:<port>/Dashboard.html
. Accessing https://<ip>:<port>/
redirects to https://<ip>:<port>/LoginPage.html
.
If we call https://<ip>:<port>/
the base URL, I would like now to change this base URL to something like https://<ip>:<port>/test/
so that
- the login and dashboard pages are available under
https://<ip>:<port>/test/LoginPage.html
andhttps://<ip>:<port>/test/Dashboard.html
respectively, and https://<ip>:<port>/test
simply redirects tohttps://<ip>:<port>/test/LoginPage.html
.
Because the file etc/org.ops4j.pax.web.cfg
specifies etc/jetty.xml
as its config file, I was assuming that I can configure this in jetty.xml. The current jetty.xml is the standard one. jetty documentation says that one can set the context path by adding the following:
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/test</Set>
</Configure>
But, adding simply the above to the end of the standard jetty conf file causes that my web pages are not reachable at all. I cannot find any further documentation or example how I could get this work...
I would appreciate any help very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请指定您正在使用的PAX Web版本。在PAX Web 8中,白板上下文配置和选择已完全实现。
有蓝图示例这声明了servlet,过滤器,错误页面和欢迎文件,但它不执行您想要的(您要注册
servletContexThelper
whiteboard service)。还有白板非蓝图样本使用非标准
org.ops4j.pax.web.service.whiteboard.httpcontextmapping 。
因此,我不能指出您适当的示例,但是简而言之,您需要三件事:
org.osgi.service.http.context.servletcontexthelper
您必须扩展此类,因为它是抽象的。您也可以重复使用
org.ops4j.pax.web.service.spi.context.defaultservletservletcontexthelper
PAX Web 8使用标准白板服务注册属性正确处理上下文选择。
Please specify which Pax Web version you're using. In Pax Web 8, whiteboard context configuration and selection is fully implemented.
There's a blueprint example that declares servlets, filters, error pages and welcome files but it doesn't do what you want (you want to register a
ServletContextHelper
whiteboard service).There's also a whiteboard non-blueprint sample that registers a context using non-standard
org.ops4j.pax.web.service.whiteboard.HttpContextMapping
.So I can't point you to proper sample, but in short words, you need three things:
org.osgi.service.http.context.ServletContextHelper
You have to extend this class, because it's abstract. You could also reuse
org.ops4j.pax.web.service.spi.context.DefaultServletContextHelper
Pax Web 8 correctly handles context selection using standard Whiteboard service registration properties.