0

I have a big problem with the struts2 validation. It's working fine in most of my fields but not in my long fields.

If I enter a string in the long field it's showing an English message instead of my message declared.

Invalid field value for field "borrower.matNo".

In my messages_de.properties it says:

exception.borrowerMatNo = Bitte geben Sie eine Nummer als Matrikelnummer an.

from the validation xml. (Having right name, hundred times checked)

<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.2//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
<validators>
   <field name="borrower.matNo">
      <field-validator type="int">
         <param name="min">
         1</param>
         <param name="max">
         100000</param>
         <message key="exception.borrowerMatNo"/>
      </field-validator>
   </field>
</validators>

From the jsp:

<s:form action="searchBorrower">
   <s:textfield key="borrower.matNo" />
   <s:submit key="search" />
</s:form>
4

1 回答 1

1

无效的字段值不是 valdation.xml 的问题。这是 Struts2 TypeConversion 错误。要设置 I18n 消息,请尝试以下操作:

invalid.fieldvalue.borrower.matNo=Please enter the correct format.
于 2013-11-03T11:29:15.673 回答