简体   繁体   English

AngularJS收到回复

[英]AngularJS get post response

I have one AngularJS project. 我有一个AngularJS项目。 it is using as front end, and I have a Java web application as a back end. 它用作前端,而我有一个Java Web应用程序作为后端。 From AngularJS project, I am redirecting to a URL which is outside of the applications(both Java and AngularJS). 从AngularJS项目中,我将重定向到应用程序之外的URL(Java和AngularJS)。 From that site, It is processing the request and returning to the AngularJS application, with some data as post. 从该站点,它正在处理请求并返回AngularJS应用程序,并将一些数据发布。

My Java application runs on 我的Java应用程序在

http://localhost:8080/myjavaapp

AngularJS app runs on AngularJS应用程序运行在

http://localhost:8080/myangularapp

From AngularJS app, I am redirecting to a some URL 从AngularJS应用程序中,我将重定向到某个URL

http://someotherwebsite.com/somepage?someparam=somevalue

After processing the request it sends back to AngularJS project. 处理完请求后,它将发送回AngularJS项目。

http://localhost:8080/myangularapp/#/responsepage

But that is sending as a Post. 但这是作为帖子发送的。 And I want to get a request parameter in my AngularJS application. 我想在我的AngularJS应用程序中获得一个请求参数。 But when I return to the angularJS page, it shows error 但是当我返回angularJS页面时,它显示了错误

Cannot POST /

If I used a JSP page, I could get the request parameter like 如果我使用了JSP页面,则可以得到请求参数,例如

String responseString = (String) request.getParameter("response");

But its only HTML and JS controlers in AngularJS project. 但它是AngularJS项目中唯一的HTML和JS控件。 Is it possible to send as post? 可以邮寄吗? If so, How can I get the post parameter in the JS controller? 如果是这样,如何在JS控制器中获取post参数?

EDIT 编辑

From other site if it's redirecting like 从其他网站重定向

http://localhost:8080/myangularapp/#/responsepage?response=somevalue

Then it's a GET request, and easily I can get the value of response using $routeParams . 然后这是一个GET请求,很容易我可以使用$routeParams获得response的值。 it's like $http.get("someurl?response=value") 就像$http.get("someurl?response=value")

But in this usecase, It is sending as a POST request. 但是在这种情况下,它是作为POST请求发送的。 Like $http.post("someurl") . 就像$http.post("someurl") Parameters are POST and I am not able to get the value. 参数是POST ,我无法获取该值。 How can I get it? 我怎么才能得到它?

Thanks. 谢谢。

It sounds like you're trying to use an angular browser application like a server application. 听起来您正在尝试使用像服务器应用程序这样的角度浏览器应用程序。 Can't you get the Java application to talk to the other application? 您不能让Java应用程序与其他应用程序对话吗? Does the other application support JSONP? 其他应用程序是否支持JSONP? If so is there a payload you can send from the ng app and get the response back. 如果有的话,您可以从ng应用程序发送有效负载并返回响应。 AFAIK you can't post to a browser, so the architecture sounds wrong. 您无法发布到浏览器的AFAIK,所以体系结构听起来不对。 There are too many question to answer this question but I couldn't put all this in a comment. 有太多问题无法回答这个问题,但我无法在评论中全部提及。 Could you use this: 你能用这个吗:

$http.jsonp('http://someotherwebsite.com/somepage?someparam=somevalue');

You are not post to the server you're using a GET (Querystring) and this will give you the other apps payload. 您没有发布到使用GET(查询字符串)的服务器上,这将为您提供其他应用程序的负载。

hope this helps 希望这可以帮助

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

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