Question

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>
Was it helpful?

Solution

Invalid field value is not a problem of the valdation.xml. It's the Struts2 TypeConversion error. To setup I18n messages try the following:

invalid.fieldvalue.borrower.matNo=Please enter the correct format.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top