In the Java EE architecture, a **web module** is the smallest deployable and usable unit of web resources. A web module contains web components and static web content files, such as images, which are called **web resources**. A Java EE web module corresponds to a web application as defined in the Java Servlet specification.
In the Java EE architecture, a **web module** is the smallest deployable and usable unit of web resources. A web module contains web components and static web content files, such as images, which are called **web resources**. A Java EE web module corresponds to a web application as defined in the Java Servlet specification.
In addition to web components and web resources, a web module can contain other files:
In addition to web components and web resources, a web module can contain other files:
除了web组件和web资源, web模块中还可以包含其他文件:
除web组件和web资源以外, web模块中还可以包含其他文件:
- Server-side utility classes, such as shopping carts
- Server-side utility classes, such as shopping carts
...
@@ -16,15 +16,15 @@ In addition to web components and web resources, a web module can contain other
...
@@ -16,15 +16,15 @@ In addition to web components and web resources, a web module can contain other
- 服务端运行所需的工具类
- 服务端运行所需的工具类
- 客户端工具类, 主要是 Applet 即相关的工具类, 基本上已废弃。
- 客户端类, 主要是 Applet 和相关依赖, 基本上已废弃。
A web module has a specific structure. The top-level directory of a web module is the **document root** of the application. The document root is where XHTML pages, client-side classes and archives, and static web resources, such as images, are stored.
A web module has a specific structure. The top-level directory of a web module is the **document root** of the application. The document root is where XHTML pages, client-side classes and archives, and static web resources, such as images, are stored.
A web module needs a `web.xml` file if it uses JavaServer Faces technology, if it must specify certain kinds of security information, or if you want to override information specified by web component annotations.
A web module needs a `web.xml` file if it uses JavaServer Faces technology, if it must specify certain kinds of security information, or if you want to override information specified by web component annotations.
如果使用 JavaServer Faces 技术, 则 web module 需要有 `web.xml` 文件, 用来指定特定类型的安全信息, 或者覆盖 web component 上通过注解指定的信息。
使用 JavaServer Face 技术时, 如果需要指定特别的安全信息, 或者覆盖 web component 上的注解配置, 则需要通过 `web.xml` 文件来指定。
You can also create application-specific subdirectories (that is, package directories) in either the document root or the `WEB-INF/classes/` directory.
You can also create application-specific subdirectories (that is, package directories) in either the document root or the `WEB-INF/classes/` directory.
A web module can be deployed as an unpacked file structure or can be packaged in a JAR file known as a Web Archive (WAR) file. Because the contents and use of WAR files differ from those of JAR files, WAR file names use a `.war` extension. The web module just described is portable; you can deploy it into any web container that conforms to the Java Servlet specification.
A web module can be deployed as an unpacked file structure or can be packaged in a JAR file known as a Web Archive (WAR) file. Because the contents and use of WAR files differ from those of JAR files, WAR file names use a `.war` extension. The web module just described is portable; you can deploy it into any web container that conforms to the Java Servlet specification.
You can provide a runtime deployment descriptor (DD) when you deploy a WAR on GlassFish Server, but it is not required under most circumstances. The runtime DD is an XML file that may contain such information as the **context root** of the web application, the mapping of the portable names of an application's resources to GlassFish Server resources, and the mapping of an application's security roles to users, groups, and principals defined in GlassFish Server. The GlassFish Server web application runtime DD, if used, is named `glassfish-web.xml` and is located in the `WEB-INF` directory. The structure of a web module that can be deployed on GlassFish Server is shown in Figure 5-3.