Jsf url扩展名

时间:2013-06-12 05:22:19

标签: jsf primefaces facelets

我刚刚开发了一个使用jsf和jpa的小应用程序,我关于url扩展的小问题,当我一次又一次地点击href函数时我会得到这样的网址

http://localhost:8082/ProjectName/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/pages/addUser.xhtml

当点击主页链接时,它显示为

http://localhost:8082/ProjectName/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/faces/pages/homePage.xhtml

它继续增加/ faces / more。

我的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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>ProjectName</display-name>

    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
      </context-param>
   <welcome-file-list>
        <welcome-file>faces/login.xhtml</welcome-file>
    </welcome-file-list>

     <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>
  <listener>
    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
  </listener>
</web-app>

我在xhtml中的href链接页面是

<!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:ui="http://java.sun.com/jsf/facelets"
      xmlns:i="http://primefaces.prime.com.tr/touch"
      xmlns:p="http://primefaces.prime.com.tr/ui"> 

<h:head></h:head> 
<body> 
<h:form>
    <a href="../faces/pages/homePage.xhtml">Home</a>
    <br />
    <a href="../faces/pages/addUser.xhtml">Create User</a>
    <br />
    <a href="deleteOrder.jsf">Change Password</a>
    <br />
    <a href="findOrderById.jsf">Allocation Tan</a>
    <br />
    <a href="findOrderById.jsf">Batch Upload</a>
    <br />
    <a href="findOrderById.jsf">XML Validation</a>
    <br />
    <a href="../faces/login.xhtml">Logout</a>
</h:form>
</body> 
</html>

和我的faces-config.xml

<?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_1_2.xsd"
    version="1.2">
     <navigation-rule>
        <navigation-case>
            <from-outcome>login</from-outcome>
            <to-view-id>/login.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
    <managed-bean>
        <managed-bean-name>home</managed-bean-name>
        <managed-bean-class>com.cation.action.LoginAction</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>      
    </managed-bean>
    <navigation-rule>
        <navigation-case>
            <from-outcome>home_page</from-outcome>
            <to-view-id>/pages/homePage.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
     <managed-bean>
        <managed-bean-name>user</managed-bean-name>
        <managed-bean-class>com.cation.action.UserAction</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>      
    </managed-bean>
    <navigation-rule>
        <navigation-case>
            <from-outcome>addUser</from-outcome>
            <to-view-id>/pages/addUser.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
</faces-config> 

任何人都可以帮我解决它。

0 个答案:

没有答案