我有一个非常简单的 web.xml 文件:
<?xml version="1.0" encoding="UTF-8" ?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<welcome-file-list>
<welcome-file>abcd.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>foo</param-name>
<param-value>bar</param-value>
</context-param>
</web-app>
我的应用程序中有 2 个 jsp 文件 hello.jsp 和 abcd.jsp。
我将战争文件部署到 Glassfish 服务器,上下文根是“novone”
当我转到 localhost:8080/novone 时,我看到的是 hello.jsp,而不是 abcd.jsp...
在 Glassfish 管理面板(local4848/common/index.jsf) Applications->novone->Descriptor->Description-File 我看到:
<?xml version="1.0" encoding="UTF-8" ?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<welcome-file-list>
<welcome-file>abcd.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>foo</param-name>
<param-value>bar</param-value>
</context-param>
</web-app>
为什么提供 hello.jsp 而不是 abcd.jsp?
当我手动转到 /novone/abcd.jsp 时,我可以看到从应用程序范围加载的值“bar”。