问题
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