此内容没有您所选择的语言版本。

7.3. Context Root


The context root determines the URL of a deployed application. By default, the context root is identical with the application directory or archive structure; for example, if you deploy an application.war archive, which contains JSP pages in a hello directory, the JSPs in the hello directory will be available under /application/hello/.

Procedure 7.2. Rewriting the Default Context Root

You can change the context root if required. To rewrite the context root, you need to define the new context root and allow the server to use the new context.
  1. To define a new context root, add the context-root element with the new value to the deployment descriptor of the application:
    • To change the context root of a web application, add the context-root element to the jboss-web.xml file.

      Example 7.3. Example jboss-web.xml with a context root defined

      <?xml version="1.0"?>
      <jboss-web>
         <context-root>/application-root</context-root>
      </jboss-web>
      Copy to Clipboard Toggle word wrap
      The URL address for the application on localhost is

      http://localhost:8080/application-root

    • To change the context root of a servlet, change the url-pattern element in the web.xml file.

      Example 7.4. Example web.xml with a context root defined

      <?xml version="1.0"?>
      <servlet-mapping>
        <servlet-name>MapRenderer</servlet-name>
        <url-pattern>/servlet-root</url-pattern>
      </servlet-mapping>
      Copy to Clipboard Toggle word wrap
      The URL address for the servlet on localhost is

      http://localhost:8080/application-root/servlet-root

  2. To start the server with the REWRITE_CONTEXT_CHECK variable set to false, run the following command: run.sh -Dorg.apache.catalina.connector.Response.REWRITE_CONTEXT_CHECK=false
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat