0

我刚刚使用eatj.com 部署了我的第一个JSF 站点。

我已经使用 glassfish 在 netbeans 上测试了我的应用程序,并且带有 JSF 标记的站点在 localhost 上运行良好。

我已经通过 ftp 将项目文件上传到了 tomcat 服务器上的 webapps 目录下。

jsp-api.jar 文件存在于 Tomcat 服务器上的 /lib 文件中。

当我重新启动服务器并转到 /webapps/myproject/web/index.xhtml 页面加载但不可见 jsf 标记。

我试图将 jar 库复制到 /webapps/myproject/web/WEB-INF/lib/ 但是没有任何变化。

也许这与我的主页是 .xhtml 而不是 .jsf 的事实有关?但我会想如果它在我的本地主机上工作,那么它在这台服务器上工作?

我确信服务器支持 JSF,因为有运行 JSF 页面的示例。

任何帮助将不胜感激。

谢谢

编辑:

下面是我当前的 web.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
<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>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
<welcome-file-list>
    <welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>

编辑:

下面是我的 catalina.out 文件中用于服务器启动的粘贴:

INFO: Server startup in 1594 ms
May 7, 2012 1:09:50 PM org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-6713
May 7, 2012 1:09:51 PM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
May 7, 2012 1:09:51 PM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-6713
May 7, 2012 1:09:57 PM org.apache.catalina.core.AprLifecycleListener init
INFO: 
May 7, 2012 1:09:57 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-6713
May 7, 2012 1:09:57 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1017 ms
May 7, 2012 1:09:57 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
May 7, 2012 1:09:57 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.14
May 7, 2012 1:09:59 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-6713
May 7, 2012 1:09:59 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:4713
May 7, 2012 1:09:59 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/62  config=null
May 7, 2012 1:09:59 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1580 ms
4

1 回答 1

0

仅当请求 URL 与in匹配时<url-pattern>,才会处理 JSF 标记。您似乎已将其映射到,但of不匹配。您有 2 个选项:FacesServletweb.xml*.jsf<welcome-file>index.xhtml

  • 将 映射到FacesServletof<url-pattern>*.xhtml不是*.jsf。这样,您就无需摆弄虚拟 URL。

  • 更改并在根文件夹<welcome-file>旁边index.jsf创建一个空index.jsf文件,index.xhtml以欺骗服务器它确实存在,以防止 404 错误。

By the way, the confirmation that you've a jsp-api.jar file in Tomcat's /lib is irrelevant to this problem. First, that's standard part of Tomcat and second, that's not used at all when you're using Facelets.

Last but not least, make sure that you ship a concrete JSF implementation along with your webapp in its /WEB-INF/lib folder. Tomcat does as being a simple JSP/Servlet container namely not ship with JSF bundled, while Glassfish as being a full fledged Java EE application server does. If you don't have any one, download and drop the javax.faces.jar file in /WEB-INF/lib folder of your webapp before deploying to Tomcat. Also make sure that your web.xml is declared conform Servlet 2.5, because Tomcat 6 is a rather old version which doesn't support Servlet 3.0 like as Glassfish 3.

于 2012-05-07T14:32:06.923 回答