问题描述
我是Websphere的新手.我们已经在Websphere应用程序服务器(8.5.5)上安装了一个简单的hello world应用程序,并且将ibm http服务器的上下文根设置为/HelloWorld.下面给出的是我们用于战争的web.xml:
I am new to Websphere.We have installed a simple hello world app on the websphere application server (8.5.5) and with ibm http server with the context root set as /HelloWorld.Given below is the web.xml we are using for the war:
<?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页面的内容.但是,我得到了禁止"页面.如果使用路径http:///HelloWorld/index.jsp
When I browse to http:///HelloWorld I am expecting to see the contents of the index.jsp page of my hello world application.However I am getting the "Forbidden" page. I see the contents if I use the path http:///HelloWorld/index.jsp
一些在线帖子/文档将我带到服务器上的plugin-cfg.xml文件.我已经编辑了文件,以手动将Uri"/HelloWorld/*"添加到默认的URIGroup,并且可以正常工作.
Some posts/documentation online lead me to plugin-cfg.xml file on the server.I have edited the file to add the Uri "/HelloWorld/*" to the default URIGroup manually and it works.
现在我的问题是如何使用管理控制台将Uri添加到UriGroup?还有一种方法可以通过部署战争来添加路由,而不用显式地编辑plugin-cfg文件.
Now my question is how do I add a Uri to the UriGroup using the Adminsitration Console?Also is there a way to have the route added via the war being deployed instead of editing the plugin-cfg file explicitly.
更新:现在可以正常工作了,我假设在部署过程中将模块映射到群集(将模块映射到服务器"步骤)将自动将其映射到Web服务器,但显然不是.我已经将该模块映射到群集和Web服务器,并且可以正常工作,我将再次从头开始重做整个部署,以确保我的理解是正确的,然后更新该帖子.
Update:It's working now I assumed that mapping the module to the Cluster during deployment ("Map modules to servers" step) will automatically map it to the web server, but apparently not. I have mapped the module to the cluster and the web server and it works I will just redo the whole deployment from scratch again to make sure my understanding is correct and then update the post.
感谢@dbreaux
Thanks @dbreaux
更新#1
我想我应该使用RTFI(I =指令).部署页面上就可以解决我的问题.
I guess I should RTFI (I = Instruction). The fix for my issue was right there on the deployment page.
推荐答案
因此,首先,应该由web.xml
进行一定的处理,而不是通过编辑plugin-cfg.xml
来处理.
So, first, this should be handled by web.xml
for certain, not by editing plugin-cfg.xml
.
我怀疑如果将<url-pattern>
更改为'/*',它将按预期工作.但是我希望'/'也能正常工作,因为那是默认"映射.请参阅 Servlet映射网址格式中/和/*之间的差异
I suspect if you change your <url-pattern>
to '/*', it will work as you expect. But I'd have expected '/' to work as well, as that's the "default" mapping. See Difference between / and /* in servlet mapping url pattern
但是,根据您要尝试执行的操作,可能会有更常规的方法来执行此操作.例如,web.xml
提供了<welcome-file-list>
元素,您可以在其中定义在请求纯上下文根时要提供的URL.
Depending on what you're trying to do, though, there might be more normal ways to do it. For instance, web.xml
provides a <welcome-file-list>
element where you define what URL you want provided when the plain context-root is requested.
您也完全不需要为JSP明确定义<servlet>
元素. WebSphere会自动理解这些内容.
You also don't need to explicitly define <servlet>
elements for JSPs at all. Those are understood automatically by WebSphere.
因此,在您的情况下,这应该足够了:
So in your case, this should be sufficient:
<?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>
这篇关于Websphere:如何将Uri添加到plugin-cfg.xml的UriGroup中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!