在Netbeans的Java EE项目中,index.jsp是默认的,在哪里?

use*_*227 9 netbeans glassfish java-ee

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

MaV*_*SCy 15

默认情况下,在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>
Run Code Online (Sandbox Code Playgroud)

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

UPDATE

明确地为tomcat ....

如果应用程序中未提供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>
Run Code Online (Sandbox Code Playgroud)

这就是默认情况下显示index.jsp的原因


小智 6

如果您使用的是netBeans,则需要单击项目上的右键,然后单击属性.将打开一个新的弹出窗口,在左侧菜单上将有一个标签调用运行.单击那里然后在您应该放置的"相对URL"

./nameOfYourJspFile.jsp
Run Code Online (Sandbox Code Playgroud)

这就是全部,希望它有所帮助!