在WebSphere Application Server 7.0上设置URL资源? [英] Setting up a URL resource on WebSphere Application Server 7.0?

查看:115
本文介绍了在WebSphere Application Server 7.0上设置URL资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在WebSphere中设置URL资源,并遵循教程.但是,本教程要求使用WebSphere Studio修改WebSphere的 web.xml ibm-web-bnd.xml .我没有WebSphere Studio,所以我需要使用文本编辑器手动修改这些文件.我试图搜索"这两个文件,但是搜索结果"太多了,我不知道哪一个是正确的文件.

I need to setup a URL resource in WebSphere and is following this tutorial. However, the tutorial requires the modification of WebSphere's web.xml and ibm-web-bnd.xml using WebSphere Studio. I don't have a WebSphere Studio so I need to modify those files manually using a text editor. I tried to "search" for the 2 files but the "search results" are so many that I don't know which one is the right file.

在哪里可以找到2个文件?我还需要为resource-ref的ID设置什么值?我注意到WebSphere Studio没有用于设置resource-ref的任何文本字段,但是在其代码视图中具有一个值.

Where can I find the 2 files? Also what value do I need to set for the resource-ref's id? I notice that WebSphere Studio doesn't have any text field for setting the resource-ref's but it has a value on its code view.

谢谢!

推荐答案

web.xml是标准的JavaEE文件,其结构在Servlet规范中有详细说明.在web.xml中,声明在本地JNDI名称空间(java:comp/env)中已知的URL.

web.xml is a standard JavaEE file and its structure is well-documented in the Servlet specification. In web.xml, you declare the URL as it is known within your local JNDI namespace (java:comp/env).

web.xml应该位于WAR项目结构下方的WEB-INF内部.如果您使用IDE(例如Eclipse)创建Web项目,则应该已经为您创建了该文件(除非您使用Servlet Specification 2.5和更高版本-Servlet Specification 2.5随JavaEE 5.0一起提供-部署描述符是可选的).

web.xml should be located inside WEB-INF, underneath your WAR project structure. If you are using an IDE (such as Eclipse) to create Web projects, this file should already be created for you (unless you use Servlet Specification 2.5 and up - Servlet Specification 2.5 is included with JavaEE 5.0 - where deployment descriptors are optional).

ibm-web-bnd.xml是特定于WebSphere的文件.它包含已声明的工件(例如URL定义)与 real 工件的绑定.您应该参考IBM的文档,以了解该文件的格式.

ibm-web-bnd.xml is a WebSphere-specific file. It contains the binding of declared artifacts (such as a URL definition) into a real artifacts. You should refer to IBM's documentation in order to figure out the format of that file.

ibm-web-bnd.xml文件应与web.xml位于同一目录.

The ibm-web-bnd.xml file should be located in the same directory as web.xml.

resource-refid属性可以设置为您喜欢的任何值,只要它由ibm-web-bnd.xml中匹配的id属性进行交叉引用即可.这就是WebSphere如何将ibm-web-bnd.xml中的定义与web.xml中的定义相关联的方法.您在教程中看到的随机字符串是由RAD或WSAD创建的;您可以在其中放置任何标识符.

The id attribute of resource-ref can be set to any value you like, as long as it is cross-referenced by a matching id attribute inside ibm-web-bnd.xml. That's how WebSphere can correlate definitions in ibm-web-bnd.xml to definitions in web.xml. The random string you see in the tutorial are created by RAD or WSAD; you can place any identifier there.

编辑(添加说明)

简而言之,过程是这样的:

In a nutshell, the process is this:

  1. web.xml中,定义 local JNDI名称.那将是您的Java代码用来引用URL的名称.例如,myWebsiteUrl.您的代码将必须在java:comp/env/myWebsiteUrl上执行JNDI查找.定义大致如下:

  1. In web.xml, you define the local JNDI name. That would be the name by which your Java code is referring to the URL. For example, myWebsiteUrl. Your code will have to perform a JNDI lookup on java:comp/env/myWebsiteUrl. The definition is along these lines:

<resource-env-ref>
    <resource-env-ref-name>myWebsiteUrl</resource-env-ref-name>
    <resource-env-ref-type>java.net.URL</resource-env-ref-type>
</resource-env-ref>

  • 在WebSphere本身中,添加URL定义.关键是在WebSphere的JNDI树中的JNDI名称​​ 中,通过该名称将知道URL.您可以在此处设置任何值,尽管(按照惯例)建议您在其前面加上url/作为前缀.例如:url/test.

  • In WebSphere itself, add a URL definition. The key there is the JNDI name in WebSphere's JNDI tree by which the URL will be known. You can set any value there, although it is recommended (by convention) that you prefix it with url/. For example: url/test.

    ibm-web-bnd.xml中,您需要将myWebsiteUrl(由应用程序查找)绑定到url/test(WebSphere知道URL的JNDI名称).定义如下:

    In ibm-web-bnd.xml, you need to bind myWebsiteUrl (looked-up by your application) to url/test (which is the JNDI name by which WebSphere knows the URL). The definition will be along the lines of:

    <resource-env-ref name="myWebsiteUrl" binding-name="url/test"/>
    

  • 不需要步骤3.如果在部署时不存在ibm-web-bnd.xml,则基于GUI的部署流程(在通过WAS管理控制台部署应用程序时使用)将提示您输入绑定值. (如果您使用脚本进行部署,只要您以其他方式指定绑定,您仍然可以省略ibm-web-bnd.xml文件,但这超出了此答案的范围.请阅读有关 strategy文件的IBM文档AdminApp.installApplication)

    Step 3 is not required. If ibm-web-bnd.xml doesn't exist at deployment time, then the GUI-based deployment flow (used when you deploy applications through the WAS administration console) will prompt you for the binding values. (If you are deploying using scripting, you can still omit the ibm-web-bnd.xml file as long as you specify the bindings in a different way, but that's beyond the scope of this answer. Read the IBM documentation about strategy files and AdminApp.installApplication)

    注意:只要使用JavaEE 5.0及更高版本,定义中就不需要id属性.顺便说一句,您正在阅读的文章已经过时了.

    Note: as long as you use JavaEE 5.0 and up, you don't need the id attribute in the definitions. The article you're reading, by the way, is extremely outdated.

    这篇关于在WebSphere Application Server 7.0上设置URL资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆