JSF没有被渲染 [英] JSF not being rendered
问题描述
我有一个带有 index.jsp 的小型webapp转发(它主要只包含):
I've got a tiny webapp with index.jsp that forwards (it mostly only contains):
<jsp:forward page="/pages/inputname.jsf" />
web.xml 包含(除了您期望的其他所有内容) ;见下文更多内容):
web.xml contains (in addition to everything else you'd expect; see more below):
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
inputname.jsp 未呈现(这是URI):
inputname.jsp isn't rendering (here's the URI):
http://localhost:8080/simpleWeb/index.jsp
页面出现在浏览器中(标签,输入编辑字段,按钮):
The page appears thus in the browser (label, input edit field, button):
#{msg.prompt} #{personBean.personName} #{msg.button_text}
我猜这是因为它没有通过Faces servlet。但是,我不确定如何强制通过。 (请注意,我在其他地方,使用RichFaces和MyFaces,也遇到与 .xhtml 文件类似的问题,但我想首先解决这个更简单的案例。)
I'm guessing this is because it's not getting through the Faces servlet. However, I'm uncertain of how to force it through. (Note that I'm elsewhere, with RichFaces and MyFaces, having similar trouble with .xhtml files too, but I'd like to get this simpler case solved first.)
本教程让我使用这些库(通过Maven),在WEB-INF / lib /中:
The tutorial has me using these libraries (via Maven), in WEB-INF/lib/:
avalon-framework-4.1.3.jar
commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
commons-digester-1.8.jar
commons-logging-1.1.jar
jsf-api-1.2_02.jar
jsf-impl-1.2-b19.jar
jstl-1.1.2.jar
log4j-1.2.12.jar
logkit-1.0.1.jar
servlet-api-2.3.jar
standard-1.1.2.jar
我们非常感谢任何帮助。
Any help would be greatly appreciated.
web.xml (是的,它有DOCTYPE网络应用标题):
web.xml (yes, it has the DOCTYPE web-app header):
<web-app>
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
推荐答案
两种解决方案:
- 需要将
index.jsp
称为index.jsf
通过浏览器。 -
index.jsp
应该触发重定向而不是转发。 JSTL< c:重定向>
可能有用。
- The
index.jsp
needs to be called asindex.jsf
by browser. - The
index.jsp
should fire a redirect rather than forward. JSTL<c:redirect>
may be useful.
无论如何,这样一个 index.jsp
是没有意义的。只需在 web中将
并在真实旁边提供空白 /pages/inputname.jsf
添加为< welcome-file>
。 xml /pages/inputname.jsf
文件 /pages/inputname.jsp
欺骗文件存在的服务器(否则它将变为404)。
Regardless, such an index.jsp
is pretty pointless. Just add /pages/inputname.jsf
as <welcome-file>
in web.xml
and provide a blank /pages/inputname.jsf
file next to the real /pages/inputname.jsp
to fool the server that the file exist (otherwise it will go 404).
至于 web.xml
, DOCTYPE
不属于那里。它是Servlet 2.3方法的一个古老遗留物(之前已有近十年历史)。在Servlet 2.4和更新版本中,有XSD。更重要的是,由于你使用的是JSF 1.2, web.xml
应该声明为至少 Servlet 2.4,最好是更高,最高你的容器可以支持,以便您可以使用最新的API工具。 Tomcat 5.5是Servlet 2.4,Tomcat 6.0是Servlet 2.5,Tomcat 7.0是Servlet 3.0。
As to the web.xml
, the DOCTYPE
doesn't belong there. It's an ancient remnant of Servlet 2.3 approach and before (almost a decade old already). On Servlet 2.4 and newer, there are XSD's. Even more, since you're using JSF 1.2, the web.xml
should be declared as at least Servlet 2.4, preferably higher, the highest your container can support, so that you can utilize the newest available API facilities. Tomcat 5.5 is Servlet 2.4, Tomcat 6.0 is Servlet 2.5 and Tomcat 7.0 is Servlet 3.0.
- JSF 1.2 tutorial with Eclipse and Tomcat
这篇关于JSF没有被渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!