本文介绍了Netbeans中的Java EE项目中的index.jsp默认在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Netbeans中创建了一个名为WebApplication1的简单Web应用程序。有一个文件被创建,名为 index.jsp 。当我运行应用程序时,浏览器转到 index.jsp 。在项目中没有其他地方提到它是欢迎页面,那么它是如何进入的?我在nbproject文件夹中检查了build.xml,glassfish-web.xml和所有xml,prop文件,但没有提及 index.jsp 。它是如何进行的?

解决方案

在Netbeans默认情况下,如果您创建一个没有添加框架的项目, xml)被提供。
要更改它,右键单击该项目并选择新建>其他> web>标准部署描述符(web.xml)



现在编辑web.xml并设置

 < welcome-file-list> 
< welcome-file> newjsp.jsp< / welcome-file>
< / welcome-file-list>

为了将默认值更改为newjsp.jsp

UPDATE



明确地用于tomcat ....

如果在应用程序中没有提供web.xml,Tomcat的默认web.xml($ CATALINA_HOME / conf / web.xml)被提供给应用程序。这个部署描述符有以下几行:

 <! -   - > 

< welcome-file-list>
< welcome-file> index.html< / welcome-file>
< welcome-file> index.htm< / welcome-file>
< welcome-file> index.jsp< / welcome-file>
< / welcome-file-list>

这就是为什么index.jsp默认显示的原因。


I create a simple web application in Netbeans, named WebApplication1. There is a file created, named index.jsp. When I run the app, browser goes to index.jsp. Nowhere in the project it's mentioned as welcome page, then how it's going there? I checked build.xml, glassfish-web.xml and all xml, prop files in nbproject folder, but nowhere is the mention of index.jsp. How it's taking?

解决方案

In Netbeans by default, if you create a project with no added frameworks, no deployment descriptor(web.xml) is provided.To change it, right click on the project and select New>Other>web>Standard Deployment Descriptor(web.xml)

Now edit the web.xml and set

<welcome-file-list>
    <welcome-file>newjsp.jsp</welcome-file>
</welcome-file-list>

In order to change the default to newjsp.jsp

UPDATE

Explicitly for tomcat....

If no web.xml is provided in the application, the default web.xml($CATALINA_HOME/conf/web.xml) of Tomcat is supplied to the application. This deployment descriptor has the following lines:

<!-- -->
<!-- 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>

That is why the index.jsp is shown by default

这篇关于Netbeans中的Java EE项目中的index.jsp默认在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 14:18