我在 NetBeans 中创建一个简单的 Web 应用程序,名为 WebApplication1。已创建一个文件,名为index.jsp
。当我运行应用程序时,浏览器会转到index.jsp
.
项目中没有任何地方将其称为欢迎页面。那么那里进展如何呢?
我检查了文件构建.xml, glassfish-web.xml、所有 XML 文件和 prop 文件NB项目文件夹,但没有提到index.jsp
。进展如何?
默认情况下,在 NetBeans 中,如果创建的项目没有添加框架,则没有部署描述符(文件web.xml)提供。
要更改它,请右键单击该项目并选择New>Other>web>Standard Deployment Descriptor(web.xml)
.
现在编辑web.xml文件并设置
<welcome-file-list>
<welcome-file>newjsp.jsp</welcome-file>
</welcome-file-list>
为了更改默认文件新jsp.jsp.
明确地用于Tomcat...
If no web.xml文件在应用程序中提供,Tomcat 的默认 web.xml($CATALINA_HOME/conf/web.xml) 提供给应用程序。该部署描述符具有以下几行:
<!-- -->
<!-- If you define welcome files in your own application's web.xml -->
<!-- deployment descriptor, that list *replaces* the list configured -->
<!-- here, so be sure to include any of the default values that you wish -->
<!-- to use within your application. -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
这就是为什么索引.jsp默认显示文件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)