【问题标题】:Sending form action request to another project deployed on same server将表单操作请求发送到部署在同一服务器上的另一个项目
【发布时间】:2017-06-27 22:47:02
【问题描述】:

我有两个项目部署在我的 tomcat 服务器上。我想将表单操作请求(提交时)发送到部署在同一服务器上的另一个项目中编写的服务。

类似:

<form method ="post" action="http://localhost:8081/simple-web-services/uploadQuestions" enctype="multipart/form-data">
<h3>Choose your file : </h3> <br>
<input type ="file" name ="attachment"></input><br>
<input type="submit" value="submit"></input>
</form

我怎样才能使这项工作?甚至允许这样做吗?

【问题讨论】:

  • 它应该可以工作。你得到了什么错误?
  • 404 资源未找到。它将当前项目名称添加到 url.."/TestApp/simple-web-services/uploadQuestions" ..
  • 在您的情况下,该操作必须是完整的 url。
  • 我已经使用了完整的网址,提交后网址变成了..

标签: java rest servlets


【解决方案1】:

不,它不起作用,因为它将在client 站点(浏览器)上呈现,而该站点(浏览器)对localhostport 一无所知。您必须使用该应用的外部 URL 才能向其提交 form(例如 http://somehost.com/simple-web-services/uploadQuestions)。

如果您不想在客户端站点上公开该端点(或者它在您的 servervpn 之外不可用),那么另一种方法可能是使用您的应用程序的端点并调用它 application/@987654329 @ 从你的 server 侧面应用程序内部使用,比如说 Spring 的 RestTemplate 或 java 的 HttpURLConnection

【讨论】:

    猜你喜欢
    • 2016-01-04
    • 1970-01-01
    • 2019-11-03
    • 2018-02-16
    • 1970-01-01
    • 2018-02-10
    • 1970-01-01
    • 2011-09-03
    • 1970-01-01
    相关资源
    最近更新 更多