简体   繁体   English

将Web应用程序部署到Apache Tomcat的最简单方法

[英]Easiest way to deploy web app to Apache Tomcat

I'm trying to deploy my first servlet to my server. 我正在尝试将第一个servlet部署到服务器。 There are, of course, many tutorials online. 当然,在线上有许多教程。 But most of them are very detailed and complicated, and I only need to deploy a few simply servlets to this server. 但是其中大多数都非常详细和复杂,我只需要向该服务器部署几个简单的servlet。

I found what I think to be the shortest method of deployment: Deployment on Tomcat Startup . 我发现我认为是最短的部署方法: 在Tomcat Startup上进行部署。 I moved my .WAR file ( FirstProject.war ) into $CATALINA_BASE/webapps folder, but when trying to access it ( ServerIP/FirstProject ) I get the " The requested resource is not available ." 我将.WAR文件( FirstProject.war )移到$CATALINA_BASE/webapps文件夹中,但是当尝试访问它( ServerIP/FirstProject )时,出现“ 请求的资源不可用” error. 错误。

Is there anything I forgot in the process of deployment? 在部署过程中我有什么遗忘的吗?

I know that deployOnStartup has to be set to true , but I didn't change anything with the server's hosts, so the current host is localhost . 我知道deployOnStartup必须设置为true ,但是我没有对服务器的主机进行任何更改,因此当前主机为localhost I didn't change its settings, so deployOnStartup should be true (It's said that true is the default). 我没有更改其设置,因此deployOnStartup应该为true (据说true为默认值)。

What am I missing? 我想念什么?

You are using easiest way but I don't know what you are missing. 您正在使用最简单的方法,但我不知道您缺少什么。 Here what I would suggest is run your server and access through localhost:8080 then click manage app then enter username and password then you can deploy your war. 在这里,我建议运行服务器并通过localhost:8080进行访问,然后单击管理应用程序,然后输入用户名和密码,然后进行部署。 If you have any query post command. 如果有任何查询后命令。

Even i used to face this problem while deploying my first web application on Jboss and Apache .. 即使我曾经在Jboss和Apache上部署我的第一个Web应用程序时也遇到过这个问题。

Even though your code is working properly with all your servlet mappings and paths using in your content files ...some times they kick back in real time environment ..So we have to know the proper deployment folder structure and accordingly we have to change our paths in the code 即使您的代码可以与内容文件中使用的所有servlet映射和路径一起正常工作,有时它们也会在实时环境中恢复正常运行。因此,我们必须知道正确的部署文件夹结构,因此必须更改我们的部署文件夹结构代码中的路径

what i am concluding is check the below lines of code 我的结论是检查以下代码行

   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

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

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