0

我的 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>Production</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>/faces/*</url-pattern>
    </servlet-mapping>
    <context-param>
        <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <param-name>org.richfaces.SKIN</param-name>
        <param-value>blueSky</param-value>
    </context-param>


    <!--Configuration for Richfaces-->
    <filter>
        <display-name>RichFaces Filter</display-name>
        <filter-name>richfaces</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>richfaces</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>
    <!--End of the configuration part for Richfaces-->

    <!--Configuration for Facelets-->
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.jsp</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.RECREATE_VALUE_EXPRESSION_ON_BUILD_BEFORE_RESTORE</param-name>
        <param-value>false</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.SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>
    <!--End of the configuration part for Facelets-->

</web-app>

还有我的 facelet-config 文件

<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="1.2" 
                xmlns="http://java.sun.com/xml/ns/javaee"
                xmlns:xi="http://www.w3.org/2001/XInclude"
                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-facesconfig_1_2.xsd">
<managed-bean>
    <description>Managed Bean for HomeContent</description>
    <managed-bean-name>Sample1</managed-bean-name>
    <managed-bean-class>com.test.Sample1</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</managed-bean>

我的 Facelet 是

<!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:h="http://java.sun.com/jsf/html"
     xmlns:f="http://java.sun.com/jsf/core"
     xmlns:rich="http://richfaces.org/rich"
     xmlns:a4j="http://richfaces.org/a4j">
    <f:view>
        <head>   
              <title>Facelet Page</title>
        </head>
        <body>
            <h:form id="sampleForm" binding="#{Sample1.initForm}">               
                <rich:panel>
                    <a4j:outputPanel id="sampleOutputPanel">

                        <h:outputText value="UserName : "/>
                        <h:inputText value="#{Sample1.username}"/>

                        <a4j:commandButton value="Test" 
                             reRender="sampleOutputPanel,output"
                             action="#{Sample1.displayButtonAction}"/>

                        <h:outputText id="output" 
         value="Typed username : #{Sample1.displayValue}"/>
                    </a4j:outputPanel>
                </rich:panel>
            </h:form>
        </body>
    </f:view>
</html>

当我运行我的 facelet 时,系统会提示文件下载选项。我看不到 facelet 文件。谁能告诉文件中有什么问题?

4

1 回答 1

0

使用过tomcat 7.x 版本和RIchfaces 4.x 版本,它工作正常。意识到这是由于版本不匹配。

于 2013-07-25T07:56:33.790 回答