Omnifaces 无扩展 URL 和 h:link

Omnifaces extensionless URLs and h:link

根据 http://showcase.omnifaces.org/facesviews/ExtensionlessURLs 默认情况下,由 ViewHandler.getActionURL(FacesContext, String) 生成的所有 URL,其中包括

<h:form>, <h:link>, <h:button> 

和所有扩展标签,也将是无扩展的。

我尝试通过将 Facelets 源文件放入 /WEB-INF/faces-views 目录来使用它。

我在浏览器中输入 /context/entries,然后我得到了 /WEB-INF/faces-views/entries.xhtml 中的页面。但是当我在 facelet 页面中使用它时:

<h:link outcome="entries">Entries</h:link>

url 结果是 /context/WEB-INF/faces-views/entries.xhtml,这不是理想的结果。出了什么问题?

我正在使用 Mojara 2.2.12 和 Omnifaces 2.6.9,我的人脸 servlet 映射是 *.jsf。

BalusC说的对,换2.6.8版本解决问题。功劳一如既往是BalusC的,不过他的功劳太大了,我想他不会介意我自己贴出答案,只是不想打扰他。

将 servlet 映射更改为 *.xhtml 也解决了问题。恕我直言,Xtreme Biker:bug 就是 bug。即使我将映射更改为 *.abc 也不应该有问题。

有一个 small mistake in FacesViews of specifically 2.6.9 which is fixed in 2.7-SNAPSHOT. While working on getting FacesViews to support folders with periods in names such as /foo.bar/baz, I have accidentally committed a part of the fix into 3.x only instead of into 2.x. That explains why it works just fine in 3.1, as demonstrated by the "viewsdemo" 展示。我错了,这再次证明我是人不是机器

有几种方法可以解决这个问题:

  1. 降级到 2.6.8。
  2. 或者,迁移到 3.1。
  3. 或者,保留 2.6.9 并使用单个 web.xml 上下文参数的 "Minimal configuration" 方法,而不是 "Zero configuration" 将文件放置在 /WEB-INF/faces-views 中的方法。