You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Omnifaces无扩展名URL配置后<h:link>使用问题咨询

Let's walk through the most common fixes for your <h:link> problem when using OmniFaces FacesViews:

The biggest mistake people make here is referencing the physical file path instead of the extensionless URL mapped by FacesViews. Since your entries.xhtml lives in /WEB-INF/faces-views, FacesViews exposes it at /context/entries — so your <h:link> should target this clean path directly.

Use either of these correct syntaxes:

<!-- Absolute path (most reliable, works from any page) -->
<h:link value="View Entries" outcome="/entries" />

<!-- Relative path (works if current page is in the same logical root) -->
<h:link value="View Entries" outcome="entries" />

Never include .xhtml or the /WEB-INF/faces-views prefix in the outcome — FacesViews handles the mapping behind the scenes automatically.

2. Double-Check FacesViews Defaults (If You Customized Them)

While your setup should work with default settings, confirm you haven't overridden critical parameters in web.xml:

  • Ensure org.omnifaces.FACES_VIEWS_SCAN_PATHS is either unset (defaults to /WEB-INF/faces-views) or explicitly set to your target directory.
  • Verify org.omnifaces.FACES_VIEWS_EXTENSION_ACTION is set to REDIRECT_TO_EXTENSIONLESS (the default) to enforce clean URL generation.

3. Rule Out URL Mapping Conflicts

Make sure no other servlets, filters, or custom mappings in your web.xml are handling the /entries path. Conflicting mappings can block FacesViews from resolving the URL generated by <h:link>.

4. Upgrade to the Latest OmniFaces Version

Older OmniFaces releases might have edge-case bugs with FacesViews and <h:link> URL generation. Upgrading to the latest stable version can resolve unexpected behavior.

5. Test with a Minimal Example

If the issue persists, narrow it down with a simple test:

  1. Add a test.xhtml file to /WEB-INF/faces-views
  2. Add <h:link outcome="/test">Test Link</h:link> to your homepage
  3. Check if the generated URL is /context/test (correct) or something malformed (incorrect)

This helps you confirm if the problem is specific to your entries page or a broader configuration issue.

内容的提问来源于stack exchange,提问作者cpliu338

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:49:04