简体   繁体   English

如何从JSF 2.2提取URL路径和查询参数?

[英]How to extract url path and query parameters from JSF 2.2?

I'm new to JSF. 我是JSF的新手。 I have two use cases. 我有两个用例。

1: URL: https://site.com/context/part/{partId}
2: URL: https://site.com/context/register-token?tokenType=xxxxxx&token=xxxxx

in each of these cases i'd like to extract the variable information, execute code in a java class (scoped bean/@PostConstruct, i presume) then display appropriate content based on the values. 在每种情况下,我想提取变量信息,在java类中执行代码(作用域bean / @ PostConstruct,我假定),然后根据值显示适当的内容。

I'm sure this is pretty straight forward in JSF and I have seen quite a few nice suggestions on how to do pieces of these, but they seem to not be without controversy, so I can't say they're the correct way due to my ignorance. 我确信这在JSF中是很简单的,并且我已经看到了很多有关如何做这些事情的好建议,但是它们似乎并非没有争议,因此我不能说它们是正确的方法我的无知。 Additionally there seems to be significant enough changes in 2.2 the older posts could be out of date as far as "correctness" goes. 另外,在2.2版中似乎有足够的更改,就“正确性”而言,较旧的帖子可能已过时。 Lastly there doesn't seem to be a guide (that I can find) that specifically talks to these workflows specifically in 2.2. 最后,似乎没有指南(我可以找到)专门针对2.2中的这些工作流程。

Can anyone provide me a semi comprehensive "correct" way to do these things in JEE7/JSF2.2? 谁能在JEE7 / JSF2.2中为我提供一种半全面的“正确”方法来做这些事情?

Correct can be subjective I know, but my thinking though this seems rudimentary enough that in this case a vanilla happy path suggestion would be enough. 正确可能是主观的,我知道,但是我的想法虽然基本,但在这种情况下,只要有一条幸福的道路建议就足够了。

Much appreciated, thanks. 非常感谢,谢谢。

Finishing comment from above as the last issue has been resolved... 最后的问题已解决,请从上面结束评论...

For workflow 1: i found this and it worked: http://www.oracle.com/technetwork/articles/java/jsf22-1377252.html 对于工作流程1:我发现了这一点,并且成功了: http : //www.oracle.com/technetwork/articles/java/jsf22-1377252.html

But it seemed limited to query params. 但是它似乎仅限于查询参数。

For workflow 2: I'm using prettyfaces and i was able to get it to work ~sort-of~ by using this (Section 3.6): http://ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/Configuration.html#config.actions 对于工作流程2:我使用的是prettyfaces,通过使用此工具(第3.6节),我可以使其正常工作(第3.6节): http : //ocpsoft.org/docs/prettyfaces/3.3.3/zh-CN /html/Configuration.html#config.actions

My web assets not resolving issue was resolved, by using this tip given by @chkal: PrettyFaces using mapped urls and actions, i lose all my stylings . 通过使用@chkal提供的提示解决了我的Web资产无法解决的问题: 使用映射的URL和操作提供PrettyFaces,我失去了所有样式

This suggestion pushed me over the edge to abandon a pure JSF solution and use pretty faces especially since im going to lean towards workflow 2 more often than not: Should I use f:event or action element in PrettyFaces? 这个建议迫使我放弃纯JSF解决方案并使用漂亮的面孔,尤其是因为im倾向于更倾向于工作流2: 我应该在PrettyFaces中使用f:event还是action元素?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM