在JSF2 Project中混合JSP和XHTML(Facelets)-可能吗? [英] Mixing JSP and XHTML (Facelets) in JSF2 Project - possible?
问题描述
我有一个想要使用JSF2的客户端,他们喜欢XHTML现在是默认的(Facelets).
I have a client who wants to use JSF2 and they like that XHTML is now the default (Facelets).
但是,他们的JSF1.x代码库中有大量的遗留" JSP.
However, they have a huge amount of "legacy" JSP from their JSF1.x codebase.
我知道这可能不是很理想,但是是否有可能在JSF2中同时支持这两者,至少在移植期间的过渡期内支持?
I know it's probably not desirable, but will it be possible to support a mix of both in JSF2, at least for a transition period whilst they port?
我知道可以在JSF1.x中将两者混合使用,但是我在JSF2中找不到与此相关的任何信息.
I know it was possible to mix the two in JSF1.x, but I can't find any information about this in JSF2.
我一直在努力地搜索Google,但自然而然,所有JSF2的关注点都集中在Facelets上.同样,我短暂的混合尝试(我不是JSF专家!)也导致了失败.
I've googled hard but naturally all the JSF2 focus is on Facelets. Also my brief attempt at mixing (I'm not an expert at JSF!) has led to failure.
推荐答案
Facelets常见问题解答:在FacesServlet
上使用前缀映射.然后,您可以通过 http://example.com/faces/page.jsp 访问JSP页面,然后通过 http://example.com/faces/page.xhtml 的Facelets页面.这是一个相关的例子:
This is answered in the Facelets FAQ: use prefix mapping on FacesServlet
. You can then access JSP pages by http://example.com/faces/page.jsp and Facelets pages by http://example.com/faces/page.xhtml. Here's a cite of relevance:
如何在同一应用程序中使用Facelets和JSP?
您必须对Facelets页面使用前缀映射,才能使其工作.将
DEFAULT_SUFFIX
保留为JSF默认值.jsp
.配置Facelet的VIEW_MAPPINGS
参数:
How do I use Facelets and JSP in the same application?
You have to use prefix mapping for the Facelets pages in order for this to work. Leave the
DEFAULT_SUFFIX
with the JSF default of.jsp
. Configure the Facelet'sVIEW_MAPPINGS
parameter:
<web-app>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
</context-param>
<!-- Facelets pages will use the .xhtml extension -->
<context-param>
<param-name>facelets.VIEW_MAPPINGS</param-name>
<param-value>*.xhtml</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<!-- Use prefix mapping for Facelets pages, e.g. http://localhost:8080/webapp/faces/mypage.xhtml -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
</web-app>
这篇关于在JSF2 Project中混合JSP和XHTML(Facelets)-可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!