java.lang.NoSuchMethodError:com.ocpsoft.pretty.faces.beans.ExtractedValuesURLBuilder.build(...) 当我在搜索结果页面中使用时
以下是我的配置详情
的web.xml
<context-param>
<param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
使用Jars prettyfaces-jsf2-3.1.0.jar prettyfaces核-3.3.2.jar
漂亮-config.xml中
<url-mapping id="mySearch-result">
<pattern value="/#{mySearchMBean.addressId}/"/>
<view-id value="/pages/mySearch-result.xhtml"/>
<action>#{mySearchMBean.doLookupForAddress}</action>
</url-mapping>
mySearch.xhtml
<h:form>
Search Address by id:<br />
<h:inputText value="#{mySearchMBean.addressId}" /><br />
<h:commandButton type="submit" value="Submit" action="pretty:mySearch-result" inclueViewParams="true">
</h:commandButton>
</h:form>
ManagedBean和操作方法
@ManagedBean(name="mySearchMBean")
@RequestScoped
public class MySearchMBean {
public String doLookupForAddress() {
MySearchDAO dao = new MySearchDAO();
adresss = dao.findAddressById(addressId);
System.out.println("doLookupForAddres");
return "mySearch-result";
}
}
MYSEARCH-result.xhtml
<h:form>
<p><b>ADDRESS ID:</b> ${mySearchMBean.adresss.addressId}</p>
<p><b>NAME:</b> ${mySearchMBean.adresss.name}</p>
<p><b>STREET:</b> ${mySearchMBean.adresss.street}</p>
<p><b>LOCATION:</b> ${mySearchMBean.adresss.location}</p>
<p><b>ZIP:</b> ${mySearchMBean.adresss.zip}</p>
<h:form>
如果我在mySearch-results.xhtml页面中使用h:form,其根本原因如下所示:
java.lang.NoSuchMethodError: com.ocpsoft.pretty.faces.beans.ExtractedValuesURLBuilder.build(Lcom/ocpsoft/pretty/faces/config/mapping/UrlMapping;)Ljava/lang/String;
com.ocpsoft.pretty.faces.application.PrettyViewHandler.getActionURL(PrettyViewHandler.java:124)
javax.faces.application.ViewHandlerWrapper.getActionURL(ViewHandlerWrapper.java:189)
javax.faces.application.ViewHandlerWrapper.getActionURL(ViewHandlerWrapper.java:189)+
如果我从mySearch-result页面删除<h:form>
,则其工作正常。
我是Prettyfaces的新手,
我错过了什么吗?我的配置和网址映射是否正确? 感谢。
答案 0 :(得分:1)
您正在混合使用不同的PrettyFaces版本:
prettyfaces-jsf2-3.1.0.jar
prettyfaces-core-3.3.2.jar
将两者都更新到3.3.3,一切都会好的。