如何在使用 tomcat8 本地服务器时将自定义 JSP 项目 url 设置为默认值 url?

How to set custom JSP project url to default url on using tomcat8 local server?

我安装了 Tomcat8 并在 webapps 目录中上传了 jsp 项目。 现在我可以使用 url 访问我的站点,例如“http://sitename/project name/web”。 但我希望我的项目在访问“http://sitename”时显示。 我试图找到解决方案,但没有任何帮助。 请帮我。 谢谢。

尝试在 webapps 目录中创建名为 ROOT 的目录并将其放入您的 jsp 文件并重命名为 index.jsp.

如果您在webapps目录中创建ROOT目录或ROOT.war,则无需/[context-name]即可访问该应用程序,如“http://sitename/your.jsp”。

此外,Tomcat通过conf/web.xml中的以下默认设置将index.jsp视为欢迎文件:

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

因此您可以通过请求“http://sitename”来访问 ROOT/index.jsp