问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/15046821/why-dont-my-jsf-tags-work



