英文:
How do I take forward a session from a authenticator POST request into a GET request in JAVA?
问题
我有一段 Java 代码,其中一个 POST 请求通过使用上述链接中提到的 MgntUtils 库正常工作。
以下是代码部分:
HttpClient client = new HttpClient();
client.setContentType("application/json; charset=utf-8");
client.setConnectionUrl("http://egurl/app/app1/session/login");
client.sendHttpRequest(HttpMethod.POST, "{\"username\":\"acd\",\"password\":\"pwd\",\"isPasswordEncrypted\":\"false\"}");
我需要使用相同的会话并将其用于从不同的 URL 获取一些数据,例如:http://egurl/app/app1/param/paramgrp/1234
是否有一种方法可以使用会话来完成这个任务。我在使用 Java 中的 GET
和 POST
方面相对较新,所以需要一些帮助。
谢谢。
英文:
please refer to this <https://stackoverflow.com/questions/63011809/java-equivalent-of-a-curl-cookie-statement/63012623?noredirect=1#comment111607622_63012623>
I have a Java code where a post request works perfectly as follows using MgntUtils library as mentioned in the above link.
here the code :
HttpClient client = new HttpClient();
client.setContentType("application/json; charset=utf-8");
client.setConnectionUrl("http://egurl/app/app1/session/login");
client.sendHttpRequest(HttpMethod.POST, "{\"username\":\"acd\",\"password\":\"pwd\",\"isPasswordEncrypted\":\"false\"}");
i need to use the same session and use it to get some data from a different URL eg. http://egurl/app/app1/param/paramgrp/1234
is there a way i can use session to get this done. i am fairly new to GET
and POST
in JAVA so need some help.
Thanks/
答案1
得分: 0
这可以通过使用jsoup封装类来实现。请访问此链接以获得更好的理解。
英文:
This can be achieved using jsoup wrapper classes. please follow this link to have a better understanding.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论