我正在尝试在MVEL表达式语言的OVAL XML配置文件中编写以下java Assert语句的等价物。但我无法这样做。任何帮助将不胜感激。
public class BusinessObject
{
// mailingAddress must either be the delivery address or the invoice address
@Assert(expr = "_value ==_this.deliveryAddress || _value == this.invoiceAddress", lang = "groovy")
public String mailingAddress;
}
xml ..
<class type="BusinessObject" applyFieldConstraintsToSetters="true" overwrite="false">
<field name="mailingAddress">
<assert lang="mvel" expr="_value ==_this.deliveryAddress || _value == this.invoiceAddress" message="mailingAddress must either be the delivery address or the invoice address ">
</assert>
</field>
答案 0 :(得分:0)
这应该有效:
<class type="BusinessObject" applyFieldConstraintsToSetters="true" overwrite="false">
<field name="mailingAddress">
<assert lang="mvel" message="mailingAddress must either be the delivery address or the invoice address">
<expr>_value ==_this.deliveryAddress || _value == this.invoiceAddress</expr>
</assert>
</field>
</class>