簡體   English   中英

如何讓Glassfish自動“找到”index.xhtml並通過JSF呈現它

[英]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-patternFaces Servlet被映射到是否請求URL,該URL模式相匹配,如果是,則它調用Faces Servlet和請求將被處理Faces Servlet

只需在web.xml中為index.html添加一個<request-mapping> ,即任何負責呈現JSF頁面的servlet。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM