我正在尝试构建自定义URL,因为prettyfaces可以做到,但是在设置它之后,它给了我这个错误:
Referenced file contains errors (http://ocpsoft.org/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd). For more information, right click on the message in the Problems View and select "Show Details..."
这是我的
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>BRAINSET</display-name>
<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>
<welcome-file-list>
<welcome-file>index.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>*.xhtml</url-pattern>
</servlet-mapping>
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>
</web-app>
还有我的
pretty-config.xml
:<pretty-config xmlns="http://ocpsoft.org/prettyfaces/3.3.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.org/prettyfaces/3.3.3
http://ocpsoft.org/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd">
<url-mapping id="home">
<pattern value="/home" />
<view-id value="/index.xhtml" />
</url-mapping>
遇到这个错误,我什至无法在
Glassfish
中部署我的应用程序:Could not publish to the server.
java.lang.NullPointerException
任何想法如何解决这个问题?还是我应该寻找与
prettyfaces
类似的其他工具?更新
最佳答案
我认为此错误不是由PrettyFaces引起的。 XML模式在我的Eclipse设置中运行良好,并且没有任何这些错误。而且我非常确定XSD文件有效。
您应该查看Eclipse日志文件(WORKSPACE/.metadata/.log
),以查看是否引发任何异常。
顺便说一句:您还可以尝试从pretty-config.xml中删除schemaLocation
元素,并检查是否有帮助。解析文件时,PrettyFaces不使用XSD架构。像这样:
<pretty-config xmlns="http://ocpsoft.org/prettyfaces/3.3.3">
...
</pretty-config>