JSF2 and PrettyFaces… how does one get the original URL or the query string?

人盡茶涼 提交于 2019-12-22 10:55:40

问题


PrettyFaces is a dead simple URL rewriting engine. All sorts of SEO is possible and it is really really easy. I have one small problem though :(

Using pretty faces, I have this rewrite rule:

<url-mapping id="blogEntry">
    <pattern value="/blog/#{shortUrl}" />
    <view-id value="/blogEntry.jsf" />
</url-mapping>

So the URL bar looks like:

http://host.com/blog/first-post

And the rewrite rule maps the request internally to:

http://host.com/blogEntry?shortUrl=first-post

I'm implementing OpenID, which means I need to give the OpenID provider a return-to URL. However, when I do the following:

originalUrl = Faces.getRequest().getRequestURL().toString()

I get:

http://host.com/blogEntry.jsf

getQueryString() returns an empty string

Anyone know of way to either get the purty URL: http://host.com/blog/first-post or at minimum the query string shortUrl=first-post


回答1:


You can use: PrettyContext.getCurrentInstance().getRequestUrl().toURL() and PrettyContext.getCurrentInstance().getRequestQueryString().toQueryString()

Similar forum post: http://ocpsoft.org/support/topic/how-get-the-original-request-uri-from-jsf



来源:https://stackoverflow.com/questions/11916243/jsf2-and-prettyfaces-how-does-one-get-the-original-url-or-the-query-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!