2

我第一次发帖,所以如果我打破了协议,我很抱歉

我创建了一个项目,该项目使用 Eclipse 和 Windows 上的 tomcat 6 服务器运行 Primefaces

所有库都按原样复制,当我尝试使用 jsf 扩展名(login.jsf)访问 linux 框上的 url 时,我收到 404 错误,当我尝试使用 .xhtml 扩展名(login.xhtml)我接收代码的 xml 视图

我的 web.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  <welcome-file-list>
    <welcome-file></welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>myApp</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>WEB-INF/applicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  </servlet>
  <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</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>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
  </context-param>
  <servlet-mapping>
    <servlet-name>myApp</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
  <context-param>
    <param-name>log4jtLocation</param-name>
    <param-value>/WEB-INF/log4j.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
  </listener>
  <listener>
    <listener-class>
      org.springframework.web.context.ContextLoaderListener
   </listener-class>
  </listener>
  <listener>
    <listener-class>
          org.springframework.web.context.request.RequestContextListener
       </listener-class>
  </listener>
</web-app>

我的 login.xhtml

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:p="http://primefaces.org/ui"
          template = "template/template.xhtml">
    <h:head>

    </h:head>
    <ui:define name="body">
    <h:form id="form">

    <p:growl id="growl" showDetail="true" /> 


          <p:panel>
                <p:panelGrid columns="2">
                        <h:outputLabel value="Username:"/>
                        <p:inputText value = "#{loginUI.username}"/>

                        <h:outputLabel value="Password"/>
                        <p:password value = "#{loginUI.password}"/>


                </p:panelGrid>
                <p:commandButton value="Login" actionListener="#{loginUI.login}" update="growl"/> 

          </p:panel>
    </h:form>
    </ui:define>
    </ui:composition>
    [/code]

我的面孔配置文件

 <?xml version="1.0" encoding="UTF-8"?>

    <faces-config
        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-facesconfig_2_1.xsd"
        version="2.1">

         <application>
      <el-resolver>
              org.springframework.web.jsf.el.SpringBeanFacesELResolver
      </el-resolver>
       </application>

    </faces-config>

当我启动tomcat时,日志中没有错误

提前致谢

4

1 回答 1

0

在小服务程序中

<servlet-name>Faces Servlet</servlet-name>

<load-on-startup>1</load-on-startup>

并在 servlet

<servlet-name>myApp</servlet-name>

<load-on-startup>2</load-on-startup>
于 2012-10-22T12:11:09.093 回答