我刚刚使用 jsf 和 jpa 开发了一个小应用程序,我有一个关于 url 扩展的小问题,当我一次又一次单击 href 功能时,我得到了这个 url
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/更多。
我的 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>
谁能帮我解决它。