JSF2和PrettyFaces ......如何获得原始URL或查询字符串? [英] JSF2 and PrettyFaces... how does one get the original URL or the query string?
问题描述
PrettyFaces是一个简单的URL重写引擎。各种搜索引擎优化是可能的,它真的很容易。我有一个小问题:(
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>
所以URL栏看起来像:
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
我正在实现OpenID,这意味着我需要为OpenID提供商提供一个返回URL。但是,当我执行以下操作时:
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()
我得到:
http://host.com/blogEntry.jsf
getQueryString()返回一个空字符串
getQueryString() returns an empty string
任何人都知道如何获得purty URL: http://host.com/blog/first-post
或至少查询字符串 shortUrl = first-post
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
推荐答案
您可以使用: PrettyContext.getCurrentInstance()。getRequestUrl()。toURL()
和 PrettyContext.getCurrentInstance()。getRequestQueryString()。toQueryString()
类似的论坛帖子:
http://ocpsoft.org/support/topic/how-get-the-original-request-uri-from-jsf
这篇关于JSF2和PrettyFaces ......如何获得原始URL或查询字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!