Apache Tomcat在localhost:8080显示的是一个已经制作好的WAR文件,而不是首页。

huangapple go评论64阅读模式
英文:

Apache Tomcat is showing an already made WAR file instead of the home page at localhost:8080

问题

你好,我正在尝试通过WAR文件将我的项目提交给我的指导老师。我已经创建了WAR文件,并且正在尝试检查WAR文件是否有效。但是当我运行Tomcat并在浏览器中输入 localhost:8080 时,WAR文件被部署,而不是显示首页。

启动命令提示符:
Apache Tomcat在localhost:8080显示的是一个已经制作好的WAR文件,而不是首页。

localhost:8080
Apache Tomcat在localhost:8080显示的是一个已经制作好的WAR文件,而不是首页。

我期望的结果:
Apache Tomcat在localhost:8080显示的是一个已经制作好的WAR文件,而不是首页。

ApacheTomcat Webapps 文件夹:
Apache Tomcat在localhost:8080显示的是一个已经制作好的WAR文件,而不是首页。

英文:

Hello I am trying to pass my project to my instructor through war file. I have already made the war file and I am trying to check if the war file works. But when I run the tomcat and input the localhost:8080 in the browser a WAR file is being deployed instead of the home page

Startup command prompt:
Apache Tomcat在localhost:8080显示的是一个已经制作好的WAR文件,而不是首页。

localhost:8080
Apache Tomcat在localhost:8080显示的是一个已经制作好的WAR文件,而不是首页。

What I am expecting:
Apache Tomcat在localhost:8080显示的是一个已经制作好的WAR文件,而不是首页。
ApacheTomcat Webapps Folder:

Apache Tomcat在localhost:8080显示的是一个已经制作好的WAR文件,而不是首页。

答案1

得分: 2

可能你是在使用你的讲师定制过的 Tomcat 版本。

通常情况下,当你从互联网上下载一个“原样”的 Tomcat 时,你应该创建一个 WAR 文件(比如 calculator.war),并将其放入 webapps 文件夹中,然后你就可以通过 localhost:8080/calculator 访问它。这是默认行为,但仍然有可能部署你定制的 WAR 文件,使其可以通过 localhost:8080 访问,就像你所描述的那样。

有几种方法可以实现这样的部署,但在你的情况下,似乎在 $CATALINA_HOME$\conf\server.xml 文件中有如下条目:

<Host name="localhost" appBase="webapps" unpackWARs="true"
  autoDeploy="false" deployOnStartup="false">
    <Context path="" docBase="Calculator"></Context>
    ....
</Host>

或者,你可能有一个位于 $CATALINA_HOME\conf\Catalina\localhost\ROOT.xml 文件中的文件,其中包含关于 Calculator WAR 文件的信息。

另一个需要检查的方向是,在你的集成开发环境中,你是否将 Calculator 项目创建成了 ROOT.war。这也是将内容部署在根路径上的一种方式。

总之,我建议你阅读这个教程,因为很有可能你正在使用这些部署方法中的其中一种。

英文:

Probably you work with a tomcat version customized by your instructor.

By default when you take a tomcat downloaded from the internet "as-is" you should create a WAR (say, calculator.war) and put into webapps folder and after that you'll be able to access it by localhost:8080/calculator. That's the default behavior, but its still possible to deploy your custom war to be accessible through localhost:8080 as you've described.

There are a couple of ways to do so, but it looks like in your case there is an entry in $CATALINA_HOME$\conf\server.xml that looks something like this:

&lt;Host name=&quot;localhost&quot; appBase=&quot;webapps&quot; unpackWARs=&quot;true&quot;
  autoDeploy=&quot;false&quot; deployOnStartup=&quot;false&quot;&gt;
    &lt;Context path=&quot;&quot; docBase=&quot;Calculator&quot;&gt;&lt;/Context&gt;
     ....
&lt;/Host&gt;

Or alternatively you have $CATALINA_HOME\conf\Catalina\localhost\ROOT.xml file
that contains information about the Calculator war.

Another direction to check is that in your IDE you don't create ROOT.war out of your Calculator project. This is also a way to deploy stuff in the root context path.

All-in-all I suggest you reading This tutorial because the chances are that you somehow use one of these methods of deployment.

huangapple
  • 本文由 发表于 2020年10月25日 12:49:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/64520453.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定