Get the request URL in a JSF bean?

后端 未结 2 487
悲哀的现实
悲哀的现实 2020-12-30 01:42

How do you get the request URL in a bean backing a JSF page? I\'ve been looking through the FacesContext docs and the best way I could find seems terribly long:



        
2条回答
  •  长情又很酷
    2020-12-30 02:12

    You already have you answer :) I'm afraid you'll have to use it that way, since every HTTP request will have to be retrieve from the faces context. You could, of course, simplify some part of this method, like the faces context retrieval, but its definitively the way to go, unless you use some kind of framework that abstracts away those details and let you get to the HttpRequest Object directly.

    Regards.

提交回复
热议问题