[英]decouple the page name from the file name in jsf web.xml
I would like the page generic.xhtml to be served in response to requests for specific1.xhtml, specific2.xhtml, etc... 我希望可以响应对specific1.xhtml,specific2.xhtml等的请求而提供页面generic.xhtml。
Is there some way to set up web.xml so that several requests map to a single file without doing a redirect? 是否可以通过某种方式设置web.xml,以便多个请求映射到单个文件而无需执行重定向? The specific.xhtml name should always be displayed to the user. specific.xhtml名称应始终显示给用户。
The specific names do not match a particular pattern, such as starting with the word specific. 特定名称与特定模式不匹配,例如以“单词”开头。 I have a list of specific names that are all implemented with one page. 我列出了所有用一页实现的特定名称。
This is equivalent to having generic.xhtml?name=specific1 except that the name parameter is the file name in the request. 这与具有generic.xhtml?name = specific1相同,除了name参数是请求中的文件名。
If this cannot be handled through web.xml or some other configuration file, what is another approach? 如果无法通过web.xml或其他配置文件来处理,另一种方法是什么?
Pages are served by Tomcat 7. 页面由Tomcat 7提供服务。
I think you should use Tuckey's UrlRewriteFilter . 我认为您应该使用Tuckey的UrlRewriteFilter 。 It should be pretty easy for you to come up with rules to achieve what you want. 您很容易想出规则来实现所需的目标。 Suppose users access your page at www.yourserver.com/context/subContext/specificX.xhtml
, I think the following rule should achieve your goal (you need to test though :P): 假设用户访问您的页面, www.yourserver.com/context/subContext/specificX.xhtml
为www.yourserver.com/context/subContext/specificX.xhtml
,我认为以下规则应该可以实现您的目标(尽管需要:P进行测试):
<urlrewrite >
<rule>
<name>Specific to Generic forward</name>
<condition next="or" type="path-info">/subContext/specific1.xhtml</condition>
<condition next="or" type="path-info">/subContext/specific2.xhtml</condition>
<from>^(.*)$</from>
<to type="forward">/generic.xhtml</to>
</rule>
</urlrewrite>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.