【问题标题】:How to make facelets work?如何使facelets工作?
【发布时间】:2010-08-30 07:54:33
【问题描述】:

我创建了一个新的 Web 项目并在 MyEclipse 上启用了它的 JSF 和 Facelets 功能,然后我将它部署在 weblogic 上。一切看起来都很好,但它对我不起作用,似乎根本没有调用视图处理程序。它有什么问题?谁能帮帮我?

这是我的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.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.VIEW_MAPPINGS</param-name>
        <param-value>*.xhtml</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.DEVELOPMENT</param-name>
        <param-value>true</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
    </servlet>
    <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>*.jsf</url-pattern>
    </servlet-mapping>
</web-app>

这是我的faces-config.xml 条目:

<application>
    <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
    <locale-config>
        <default-locale>en</default-locale>
    </locale-config>
</application>

这是我的简单xhtml:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xml:lang="en" lang="en">
    <head>
        <title>My Facelets Page</title>
        <meta http-equiv="keywords" content="enter,your,keywords,here" />
        <meta http-equiv="description" content="A short description of this page." />
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <!--<link rel="stylesheet" type="text/css" href="styles.css">-->
    </head>
    <body>
        <p>
            <ui:insert name="body">This is my JavaServer Facelets page.</ui:insert>
        </p>
    </body>
</html>

【问题讨论】:

  • 请至少向我们展示您的 web.xml 和您的 facelets 模板之一:)

标签: java jsf weblogic facelets


【解决方案1】:

如果您不通过url-pattern 或FacesServlet 请求页面,就会发生这种情况。确保您的请求 URL 正确。 IE。通过http://example.com/context/page.jsf 打开页面,因此不是http://examlpe.com/context/page.xhtml。

如果这没有帮助,那么下一步是读取服务器日志以查找任何错误或警告。

【讨论】:

  • 不客气。顺便说一句,您有什么理由不使用 JSF 2.0?这些配置设置是 JSF 1.2 的典型配置。
猜你喜欢
  • 2011-11-23
  • 2011-03-11
  • 1970-01-01
  • 2010-10-06
  • 1970-01-01
  • 2011-10-23
  • 2013-01-21
  • 2013-08-04
  • 1970-01-01
相关资源
最近更新 更多