Websphere:如何将 Uri 添加到插件的 UriGroup-cfg.xml

Websphere: How to add a Uri to UriGroup of plugin-cfg.xml

我是 Websphere 的新手。 我们已经在 websphere 应用程序服务器 (8.5.5) 和 ibm http 服务器上安装了一个简单的 hello world 应用程序,上下文根设置为 /HelloWorld。 下面给出的是我们用于 war:

的 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>HelloWorld</display-name>
    <servlet>
        <servlet-name>welcome</servlet-name>
        <jsp-file>/index.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
        <servlet-name>welcome</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

当我浏览到 http:///HelloWorld 时,我希望看到我的 hello world 应用程序 index.jsp 页面的内容。 但是我得到了 "Forbidden" 页面。如果我使用路径 http:///HelloWorld/index.jsp

我会看到内容

一些 posts/documentation 在线引导我到服务器上的插件-cfg.xml 文件。 我已经编辑了文件以手动将 Uri“/HelloWorld/*”添加到默认 URIGroup 并且它有效。

现在我的问题是如何使用管理控制台将 Uri 添加到 UriGroup? 还有一种方法可以通过正在部署的 war 添加路由,而不是显式编辑 plugin-cfg 文件。

更新: 它现在正在工作 我假设在部署期间将模块映射到集群("Map modules to servers" 步骤)会自动将其映射到 Web 服务器,但显然不是。我已经将模块映射到集群和 Web 服务器并且它可以工作我将再次从头开始重新部署整个部署以确保我的理解是正确的然后更新 post.

感谢@dbreaux

更新#1

我想我应该 RTFI(I = 指令)。我的问题的修复就在部署页面上。

Map modules to servers
Specify targets such as application servers or clusters of application servers where you want to install the modules that are contained in your application. Modules can be installed on the same application server or dispersed among several application servers. Also, specify the Web servers as targets that **serve as routers for requests to this application. The plug-in **configuration file (plugin-cfg.xml) for each Web server is generated, based on the applications that are routed through.

所以,首先,这肯定应该由 web.xml 处理,而不是编辑 plugin-cfg.xml

我怀疑如果您将 <url-pattern> 更改为“/*”,它会按您预期的那样工作。但我希望“/”也能正常工作,因为那是 "default" 映射。参见 Difference between / and /* in servlet mapping url pattern

不过,根据您要执行的操作,可能有更常规的方法。例如,web.xml 提供了一个 <welcome-file-list> 元素,您可以在其中定义 URL 在请求普通上下文根时要提供的内容。

您也根本不需要为 JSP 显式定义 <servlet> 元素。 WebSphere 会自动理解这些内容。

所以在你的情况下,这应该足够了:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <display-name>HelloWorld</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>