关于 AWS Tomcat 日志显示 ajax URL 为 404 的问题。

huangapple 未分类评论58阅读模式
英文:

For the ajax url shows 404 on the AWS tomcat log

问题

我使用 MVN install 在 AWS 的 Tomcat 上部署我的代码。我是通过直接打开 AWS 名称:8080/manager/html,并上传 WAR 文件来执行此操作(我不确定这是否是正确的方法)。服务器能够成功加载 index.html,与我的预期一致,并在前端显示页面,但在调用Javascript文件中的 AJAX 时出现错误,它总是返回 404 错误。Servlet 的 URL 模式将会是这样的:

AJAX

登录 Servlet

我在本地 localhost:8080 上测试了一切正常,但在 AWS 的 Tomcat 上,日志显示如下:

Tomcat 日志

我以前从未遇到过这样的情况,是否有人能够给我一些有关可能解决方案的有用建议?

英文:

I was using MVN install deploy my code on the AWS tomcat. I did this by directly open the AWSname:8080/manager/html and upload the WAR file(I am not sure if it is the correct way). The server can load the index.html successfully as my expectation and shows page on the front-end, but error went to call AJAX, which is in Javascript file, it always return 404. The servlet's url pattern will be like this

AJAX

Login Servlet

I tested everything fine on my localhost:8080, but in the AWS tomcat, the log showed like this.

Tomcat Log

I've never met such a case before, could somebody give me some useful suggestions on the possible solutions?

答案1

得分: 0

根据您的描述,目前还不清楚您是否有多个应用程序/ WAR 文件/容器/服务器。

根据您的消息,您似乎有一个用户界面,该界面似乎没有捆绑到您的 WAR 文件中。针对这种情况,请按照以下步骤检查您的设置:

  1. 在 WAR 文件的根目录下添加一个 index.html 文件,并测试是否可以在本地访问它。

  2. 如果这个步骤成功,将其部署到 AWS,并尝试在 AWS 上访问相同的路径。

  3. 如果页面显示正常,说明您在 AWS 上正确定义了上下文。这意味着问题可能出现在您的 URL 映射上。

  4. 但是,如果页面没有显示出来,那么可能存在 URL 问题(AWS 上的 URL 错误)。

英文:

from your description it is not clear if you have multiple apps/war/containers/servers.

From your message you have a UI, which seems not to be bundled into your war file. To check in this case use these steps to check your setups

  1. Add a index.html to your root in the war file and test if you can access it locally.

  2. if this works, deploy on AWS and try to access the same path on AWS.

  3. if the page is showing, your context is defined well on AWS. So you have an issue with your URL mappings

  4. But if it does not show, you have a URL problem (wrong URL on AWS)

huangapple
  • 本文由 发表于 2020年4月7日 13:04:54
  • 转载请务必保留本文链接:https://java.coder-hub.com/61073153.html
匿名

发表评论

匿名网友

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

确定