简体   繁体   English

如何在Java EE 7应用程序中设置上下文根

[英]How to set the context root in java ee 7 application

I've seen this link and this one but I can't find the sun-web.xml anymore. 我已经看到了这个链接这一个 ,但我不能找到sun-web.xml了。 I am going through the java ee 7 tutorial, specifically the hello1 application. 我正在阅读java ee 7教程,特别是hello1应用程序。 I don't understand how the application knows that /hello1 is the context root, I mean, I don't see it specified anywhere in the web.xml file under /WEB-INF/web.xml . 我不了解应用程序如何知道/hello1是上下文根,我的意思是,我看不到它在/WEB-INF/web.xml下的web.xml文件中的任何位置指定。 How does glassfish know, and how can we change it to, perhaps, /abc for example. Glassfish如何知道,以及如何将其更改为例如/abc

By default, context root is the same as package name. 默认情况下,上下文根与程序包名称相同。

If you use wildfly or jboss, you can add jboss-web.xml to webapp/WEB-INF/ to change context root, content like: 如果使用wildfly或jboss,则可以将jboss-web.xml添加到webapp/WEB-INF/以更改上下文根,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="
      http://www.jboss.com/xml/ns/javaee
      http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
    <context-root>yourownroot</context-root>
</jboss-web>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM