eclipse 如何从 Tomcat 根目录而不是 webapp 上下文获取欢迎页面?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4824239/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get a welcome page from Tomcat root, rather than webapp context?
提问by Tony R
In Tomcat 7, I want my welcome page (index.html) to load when I access localhost:8080/. Right now, I have to go to the webapp context, localhost:8080/MyWebApp.
在 Tomcat 7 中,我希望在访问 localhost:8080/ 时加载我的欢迎页面 (index.html)。现在,我必须转到 webapp 上下文,localhost:8080/MyWebApp。
Is there a folder in Tomcat to place pages that are not part of a webapp? I'm confused how this works...
Tomcat 中是否有一个文件夹可以放置不属于 web 应用程序的页面?我很困惑这是如何工作的...
EDIT: I notice that the web.xml for the Server in Eclipse has a servlet called "default" which is mapped to "/"... I wonder if I have to change something here?
编辑:我注意到 Eclipse 中服务器的 web.xml 有一个名为“default”的 servlet,它映射到“/”......我想知道我是否必须在这里更改某些内容?
EDIT2: I found this: http://wiki.apache.org/tomcat/HowTo#How_do_I_override_the_default_home_page_loaded_by_Tomcat.3F
EDIT2:我发现了这个:http: //wiki.apache.org/tomcat/HowTo#How_do_I_override_the_default_home_page_loaded_by_Tomcat.3F
But, I already have an index.html in my ROOT folder, and still getting 404 from the root URL. If I start the server without using Eclipse, it works. What's going on here? What exactly does Eclipse do when you start the server through it? Obviously it's not reproducing the ROOT folder of my installation.
但是,我的 ROOT 文件夹中已经有一个 index.html,并且仍然从根 URL 获取 404。如果我在不使用 Eclipse 的情况下启动服务器,它就可以工作。这里发生了什么?当你通过它启动服务器时 Eclipse 究竟做了什么?显然它不会复制我安装的 ROOT 文件夹。
采纳答案by Tony R
回答by efg
You are missing ROOT folder from 'webapps
' - maybe it was deleted during installation of the other app. ROOT folder has config files for 'Welcome' page for tomcat. You can copy it from the other tar file into ../webapps
folder and you'll be good.
您缺少“ webapps
”中的ROOT 文件夹- 可能是在安装其他应用程序期间删除了该文件夹。ROOT 文件夹包含 tomcat 的“欢迎”页面的配置文件。您可以将它从另一个 tar 文件复制到../webapps
文件夹中,您会很好。
回答by Glenn
Tomcat displays a page by default. Replace this with the page you want.
Tomcat 默认显示一个页面。将其替换为您想要的页面。
回答by evandrix
In Apache Tomcat, all websites are deployed as individual web applications. You can verify this with the Tomcat configuration manager, where you are able to start/stop/reload certain web applications.
在 Apache Tomcat 中,所有网站都部署为单独的 Web 应用程序。您可以使用 Tomcat 配置管理器来验证这一点,您可以在其中启动/停止/重新加载某些 Web 应用程序。
I believe you would like to place the welcome page in path tomcat/webapps/index.html - all files located here not in a webapp of subfolders should be viewable as the root of the url.
我相信您想将欢迎页面放在路径 tomcat/webapps/index.html 中 - 位于此处而不是子文件夹的 webapp 中的所有文件都应该作为 url 的根目录可见。
It's only anything above webapps in tomcat that's protected from web browsing. maybe you can try putting the file in index.html, and setup a link preceded by ../ to indicate "go a directory level above in the tree" to fetch this required file, or try listing the directory of the url root to see in which context you're in actually.
只有在 tomcat 中 webapps 之上的任何东西都可以防止网络浏览。也许您可以尝试将文件放在 index.html 中,并设置一个以 ../ 开头的链接以指示“转到树中上方的目录级别”以获取此所需文件,或者尝试列出 url 根目录以查看您实际上处于哪种环境中。
Hope this helps clarify something at least.
希望这至少有助于澄清一些事情。