在我的JSF应用程序中调用REST服务 [英] Calling REST service in my JSF application

查看:116
本文介绍了在我的JSF应用程序中调用REST服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用JSF 1编写的遗留应用程序,但是我有这样的要求:在显示用户界面之前,必须编辑代码并在托管Bean中调用rest服务.

I have a legacy application written in JSF 1 but I have this requirement to edit the code and call a rest service in my managed bean prior to displaying the user interface.

我不太确定如何实施此操作? 有人对此有想法吗?

I am just not too sure how to implement this? Anyone have idea over this?

推荐答案

实际上,从@ManagedBean执行此操作不是一个好主意,您可以通过这种方式将演示文稿和逻辑混在一起. @ManagedBean与表示层更多相关. 无论如何,您都应该对服务执行HTTP POST或GET请求,获取答案并进行解析以获取所需的值.有关完整示例,请参见本教程: http://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/

Actually it isn't an good idea to perform this from @ManagedBean, you in this way mix here presentation and logic. @ManagedBean related more to the presentation layer. In any way you should perform HTTP POST or GET request to your service, get the answer and parse it to get the required values. See this tutorial for complete example: http://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/

这篇关于在我的JSF应用程序中调用REST服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆