![](/img/trans.png)
[英]/faces/index.xhtml Not Found in ExternalContext as a Resource in Glassfish
[英]How to get Glassfish to automatically “find” the index.xhtml and render it through JSF
我正在使用Glassfish 3.1和所有參考實現,我得到一個問題,我如何讓Glassfish看到index.xhtml並通過JSF自動呈現它,而不是制作index.html然后重定向到index.jsf(其中是index.xhtml)? 我只是在Glassfish中使用默認映射(沒有在web.xml中添加映射)所以我可以在url字段中編寫.jsf並呈現xhtml網頁。
使用這個創建index.html: <meta http-equiv="refresh" content="0; url=index.jsf" />
在每個新文件夾中都相當麻煩,這可能是更好的方法。
在web.xml中執行以下操作:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
這取決於什么url-pattern
的Faces Servlet
被映射到是否請求URL,該URL模式相匹配,如果是,則它調用Faces Servlet
和請求將被處理Faces Servlet
。
只需在web.xml中為index.html
添加一個<request-mapping>
,即任何負責呈現JSF頁面的servlet。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.