简体   繁体   English

如何让 spring MVC 应用程序直接访问通用 .com url

[英]How to have spring MVC app direct to generic .com url

So for example, if my project name is WebApp and my domain is www.google.com, when running locally I have to type in www.google.com/WebApp.例如,如果我的项目名称是 WebApp,我的域是 www.google.com,那么在本地运行时,我必须输入 www.google.com/WebApp。 That's not super easy for clients, so I was wondering if there is a way to direct to a home page when typing in www.google.com?这对客户来说不是很容易,所以我想知道是否有办法在输入 www.google.com 时定向到主页? Any tips appreciated.任何提示表示赞赏。

Where are you deploying?你在哪里部署? To get to www.google.com you have to deploy to the root context or point the root to where you deployed.要访问www.google.com您必须部署到根上下文或将根指向您部署的位置。

Deploying my application at the root in Tomcat 在 Tomcat 的根目录部署我的应用程序

You have a couple of options:你有几个选择:

Remove the out-of-the-box ROOT/ directory from tomcat and rename your war file to ROOT.war before deploying it.从 tomcat 中删除开箱即用的 ROOT/ 目录,并在部署之前将您的 war 文件重命名为 ROOT.war。

Deploy your war as (from your example) war_name.war and configure the context root in conf/server.xml to use your war file :将您的战争部署为(从您的示例中)war_name.war 并在 conf/server.xml 中配置上下文根以使用您的战争文件:

The first one is easier, but a little more kludgy.第一个更容易,但有点笨拙。 The second one is probably the more elegant way to do it.第二种可能是更优雅的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM