JSF2和PrettyFaces ......如何获得原始URL或查询字符串?

Jon*_*her 3 java url-rewriting java-ee jsf-2 prettyfaces

PrettyFaces是一个简单的URL重写引擎.各种搜索引擎优化都是可能的,这真的很容易.我有一个小问题:(

使用漂亮的面孔,我有这个重写规则:

<url-mapping id="blogEntry">
    <pattern value="/blog/#{shortUrl}" />
    <view-id value="/blogEntry.jsf" />
</url-mapping>
Run Code Online (Sandbox Code Playgroud)

所以URL栏看起来像:

http://host.com/blog/first-post
Run Code Online (Sandbox Code Playgroud)

并且重写规则将请求内部映射到:

http://host.com/blogEntry?shortUrl=first-post
Run Code Online (Sandbox Code Playgroud)

我正在实现OpenID,这意味着我需要为OpenID提供程序提供一个返回URL.但是,当我执行以下操作时:

originalUrl = Faces.getRequest().getRequestURL().toString()
Run Code Online (Sandbox Code Playgroud)

我明白了:

http://host.com/blogEntry.jsf
Run Code Online (Sandbox Code Playgroud)

getQueryString()返回一个空字符串

任何人都知道如何获得purty URL:http://host.com/blog/first-post或至少是查询字符串shortUrl=first-post

Lin*_*oln 6

你可以使用:PrettyContext.getCurrentInstance().getRequestUrl().toURL()PrettyContext.getCurrentInstance().getRequestQueryString().toQueryString()

类似的论坛帖子:http: //ocpsoft.org/support/topic/how-get-the-original-request-uri-from-jsf