从 JSP 调用 REST GET 服务
我有一个动态设置应用程序页面标题的 JSP。
但是,我希望能够调用基于系统用户获取用户详细信息的 REST 服务。我已经有了系统用户值,但需要调用后端服务从数据库中获取详细信息。这已经实现了,但我不知道如何设置 JSP 来执行此操作。
我不想使用 javascript,因为它被用于 extjs 方面。
I have a JSP that dynamically sets the page header of my application.
However, I want to be able to call the REST Service that gets user details based on the system user. I already have the system user value but need to call the backend service to get the details from the database. This is already implemented but I don't know how to setup the JSP to do this.
I do not want to use javascript as this is being used for the extjs side of things.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了从 JSP 调用 REST,您可以使用 Apache HTTPClient。完成后,您可以浏览示例以及HTTPClient 教程。 HTTPClient 支持所有 REST API 调用,包括 GET/POST 等。
另请检查以下 HTTPClient 模板以查看如何将 HTTPClient 与 REST 结合使用。您需要从 JSP 中调用类似的代码。
特别是对于 REST GET 服务,您需要从上面链接中的模板中查看以下块
In order to call REST from JSP, you could utilize Apache HTTPClient. Once you have that you could walk through the samples as well as the HTTPClient Tutorial. HTTPClient supports all REST API Call including GET/POST and others.
Check also this following HTTPClient template to see how HTTPClient can be used with REST. You need to call a similar code from your JSP.
In particular to REST GET Service, you want to look the following block from the template in the above link