问题
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?
回答1:
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/
来源:https://stackoverflow.com/questions/26878721/calling-rest-service-in-my-jsf-application