1

我正在尝试将我的第一个 servlet 部署到我的服务器。当然,网上有很多教程。但是大部分都非常详细和复杂,我只需要在这台服务器上部署几个简单的 servlet。

我发现了我认为最短的部署方法:在 Tomcat Startup 上部署。我将我的 .WAR 文件 ( FirstProject.war) 移动到$CATALINA_BASE/webapps文件夹中,但是在尝试访问它时 ( ServerIP/FirstProject) 我得到“请求的资源不可用”。错误。

我在部署过程中忘记了什么吗?

我知道deployOnStartup必须设置为true,但我没有对服务器的主机进行任何更改,因此当前主机是localhost. 我没有更改它的设置,所以deployOnStartup应该是true(据说这true是默认设置)。

我错过了什么?

4

2 回答 2

0

您正在使用最简单的方法,但我不知道您缺少什么。在这里,我建议运行您的服务器并通过 localhost:8080 访问,然后单击管理应用程序,然后输入用户名和密码,然后您可以部署您的战争。如果您有任何查询 post 命令。

于 2012-12-29T04:14:46.243 回答
0

即使我曾经在 Jboss 和 Apache 上部署我的第一个 Web 应用程序时也遇到过这个问题。

即使您的代码在内容文件中使用的所有 servlet 映射和路径都可以正常工作...有时它们会在实时环境中回退..所以我们必须知道正确的部署文件夹结构,因此我们必须更改我们的代码中的路径

我的结论是检查下面的代码行

   Examples, assuming root is http://foo.com/site/

Absolute path, no matter where we are on the site

/foo.html

will refer to http://foo.com/site/foo.html

Relative path, assuming the containing link is located in http://foo.com/site/part1/bar.html

../part2/quux.html

will refer to http://foo.com/site/part2/quux.html

or

part2/blue.html

will refer to http://foo.com/site/part1/part2/blue.html
于 2012-12-29T07:29:37.877 回答