apache Digester:addSetNestedProperties 上出现意外的 NoSuchMethodException
我在使用 Digester 时遇到问题,希望您能帮助我。我有以下 Bean:
public class MyEntry {
private String entityID;
public String getEntityID() { return this.entityID; }
public void setEntityID(final String entityID) { this.entityID = entityID; }
}
以及以下 XML 结构:
<entries>
<entry>
<MyID>
24309LAGH1
</MyID>
</entry>
</entries>
我使用 Digester API 的 addSetNestedProperties(…) 方法:
digester.addSetNestedProperties("entries/entry", "MyID", "entryID");
出现以下异常:
java.lang.NoSuchMethodException: Bean has no property named MyID
为什么 Digester 搜索名为“MyID”的属性?我根据消化器 API 将“entryID”指定为 bean 属性
谢谢:)
最好的问候 量子风暴
I have a problem using Digester and I hope you can help me. I have the following Bean:
public class MyEntry {
private String entityID;
public String getEntityID() { return this.entityID; }
public void setEntityID(final String entityID) { this.entityID = entityID; }
}
And the following XML structure:
<entries>
<entry>
<MyID>
24309LAGH1
</MyID>
</entry>
</entries>
I use the addSetNestedProperties(…) method of the digester API:
digester.addSetNestedProperties("entries/entry", "MyID", "entryID");
The following exception occurs:
java.lang.NoSuchMethodException: Bean has no property named MyID
Why is digester searching for a property named “MyID”? I specified “entryID” as bean property accorsing to the digester API
Thanks :)
Best regards
QStorm
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保 getter 和 setter 的名称是您的属性“entityID”的大写或小写。可能您的 getter 名称是这样的 -->“getEntityID”尝试对此进行更改 -->“getentityID”
编辑< /strong>
抱歉,您需要检查的属性是 -->“MyID”
Make sure the name of getters and setters like are uppercase or lowercase of your property "entityID. Probably your getter name is like this --> "getEntityID" try to change for this --> "getentityID"
Edit
Sorry, the property you have to check is --> "MyID"
[原文]
你没有使用正确的规则来执行你的任务。
尝试使用这个:
提示:通过使用例如
BasicConfigurator.configure();
在主程序中激活 log4j。输出可能非常有用。[编辑]
如果你想使用
addSetNestedProperties
:和 for
new Digester().parse(myFile)
;我认为你的例外是:
[original]
You do not use the correct rule to perform your task.
Try using this instead:
Tips: activate the log4j in your main by using for instance
BasicConfigurator.configure();
. The output can be very useful.[edit]
If you want to use
addSetNestedProperties
:and for
new Digester().parse(myFile)
;and I presume that your Exception was: