我想在actionbean上的屬性上添加表達式驗證,但我無法使其工作。我甚至嘗試過這樣的整數> 0,但仍拋出相同的異常。下面是代碼Stripes屬性上的框架表達式驗證
@Validate(required=true, minvalue=1, expression="${this > maxBudget}")
int minBudget;
int maxBudget;
我收到以下異常:
net.sourceforge.stripes.exception.StripesRuntimeException: Could not parse the EL expression being used to validate
field minBudget. This is not a transient error. Please double check the following expression for errors: ${this > maxBudget}
造成
javax.el.ELException: The identifier [this] is not a valid Java identifier as required by section 1.19 of the EL specification (Identifier ::= Java language identifier).
This check can be disabled by setting the system property org.apache.el.parser.SKIP_IDENTIFIER_CHECK to true.
我已經試過幾個變化,但每次都引發此異常。
能有人請指出這個錯誤,我在這裏做
感謝
的條件只是爲測試目的,並感謝我已經執行的另一種方法是,在其他情況下,只是我想利用表達式驗證的,因爲它需要較少代碼,我不需要查看驗證方法來查看對特定屬性進行了哪些驗證。所以如果你可以幫助我進行表達驗證工作,那麼對於上述評論我感到很抱歉 –
抱歉,我錯過了第一行。它現在在工作,非常感謝。我仍然想知道爲什麼使用'this'不像書本和官方文檔中所述的那樣工作 –
我相信'this'只能用於@Validate中的EL表達式,當'field'屬性也存在時,但文檔可能會不完全清楚這一點。 – acdhirr