使用 Java/ICEFaces 转义 URL 中的 GET 参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1849366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Escapse url GET parameters in URL with Java/ICEFaces
提问by Tam
I have a JAVA with JSF/ICEFaces application. I need to pass parameters from one page to another so I user something like:
我有一个带有 JSF/ICEFaces 应用程序的 JAVA。我需要将参数从一个页面传递到另一个页面,因此我使用以下内容:
<f:param name="eventName" value="#{item.event_name}" />
And then get it in the constructor using:
然后在构造函数中使用:
eventName = request.getParameter("eventName");
While works fine unless there is a '/' character in the string submitted, it doesn't get parsed properly. I believe I need to escape the '/' parameter with %2F and then parse it back.
除非提交的字符串中有“/”字符,否则工作正常,但无法正确解析。我相信我需要用 %2F 转义 '/' 参数,然后再解析它。
Two things: 1- How to do this in ICEFaces or JSF 2- Are there other parameter I have to escape?
两件事:1-如何在ICEFaces或JSF中执行此操作 2-是否还有其他参数需要转义?
Thanks,
谢谢,
Tam
谭
回答by Bozho
<h:outputLink value="http://google.com">click
<f:param name="eventName" value="#{param.eventName}" />
</h:outputLink>
works for me - the browser takes care of url-encoding.
对我有用 - 浏览器负责 url 编码。
Note that you can get request parameters directly in your page, using #{param.paramName}
请注意,您可以直接在页面中获取请求参数,使用 #{param.paramName}

