Is it possible to component encode a URL with a # anchor in it using h:outputLink?
I have a URL that looks like
http://server/context/page.jsf?param1=value1#state=statename::stateparam=value2
Is there anyway to the take this URL and encode the components (the two values) using h:outputLink
?
I've tried
<h:outputLink value="page.jsf">
<f:param name="param1" value="#{servervalue1}#state=statename::stateparam=#{servervalue2}"/>
<h:outputText value="#开发者_如何学C{linkname}"/>
</h:outputLink>
But it encodes the the state section of the URL so it no longer works.
That's not possible. Best what you can do is to create a custom EL function which invokes URLEncoder#encode()
like follows:
public static String urlEncode(String value) {
return URLEncoder.encode(value, "UTF-8");
}
and then use it as follows:
<h:outputLink value="page.jsf?param1=#{util:urlEncode(value1)}#state=statename::stateparam=#{util:urlEncode(value2)}">
精彩评论