为什么我的jsf标签不起作用? [英] why don't my jsf tags work?
问题描述
在Eclipse JUNO中,我开始:
- 新的动态Web项目
- 名称:JSFTest;配置:JavaServer Faces v2.0项目
- JSF Capabilites:
-
将jar复制到WEB-INF/lib(jstl-api,jstl-impl,jsf-api,jsf-impl):
-
新的HTML到WebContent:带有"New Facelet合成页面"的index.xhtml,以及其中的代码:
-
在web.xml中,我将index.xhtml写入欢迎部分
-
当我在apache tomcat 7服务器上运行它时,结果(不必理会h1标题):
那么为什么不显示出文本和按钮呢?我怎么了我在youtube上看到了很多视频,我一直关注着他们,在视频中起作用了,但对我来说却是这样.
因为您必须按照web.xml
文件中的说明,访问/faces/
虚拟文件夹下的index.xhtml
页面进行FacesServlet
url映射.
使JSF页面正常工作的一种简单方法是更改web.xml
发件人:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
收件人
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
如果您不想更改此设置,则必须将welcome-file
更改为/faces/index.xhtml
.
IMO最好是第一个选择,这样,FacesServlet
将仅处理xhtml
页,使用/faces/*
将使其处理任何其他资源,如图像,CSS和JS文件.>
In Eclipse JUNO, I started:
- new Dynamic Web Project
- Name: JSFTest; Configuration: JavaServer Faces v2.0 Project
- JSF Capabilites:
Copy jars to WEB-INF/lib (jstl-api, jstl-impl, jsf-api, jsf-impl):
new HTML to WebContent: index.xhtml with "New Facelet Composition Page", and the code inside:
in web.xml, I write the index.xhtml into the welcome part
when I run it on my apache tomcat 7 server, the result (don't bother about the h1 title):
So why doesn't it show the outtext and the button? What did I wrong? I saw a lot of video on youtube, I followed them, in the video it worked, but at me.
Because you have to access to the index.xhtml
page under /faces/
virtual folder as stated in your web.xml
file for the FacesServlet
url mapping.
A simple way to make your JSF page to work is to change the url mapping in your web.xml
From:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
To
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
If you don't want to change this, you must change your welcome-file
to /faces/index.xhtml
.
IMO it will be better the first option, in this way the FacesServlet
will only process the xhtml
pages, using the /faces/*
will make it process any other resource as images, CSS and JS files.
这篇关于为什么我的jsf标签不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!