开发者

Weird behaviour in Struts 2 validation

I have a Struts 2 app, the validation works just fine, it validates the necessary fields and throws the adequate error message. The problem comes in a very specific location i.e. character number 5838 !

In my validation.xml file I have numerous fields defined, one of them is

   <field name="idState">   
      <field-validator type="requiredstring">
        <param name="expression"><![CDATA[
           idNumber == null || idNumber.trim().length() == 0 
        || (idState != null && idState.trim().length() > 0)
          ]]></param>  
        <message>Please enter your State.</message> 
      </field-validator> 
   </field>

(Please pardon my code formatt开发者_Python百科ing !) Technically I should get the error message as

"Please enter your State." 

to my amusement I am only getting

"Please enter yo". 

And this happens at the location 5838 (ie. the error message truncates).

Now if I add a space in the tag as I get

"Please enter y". 

I noticed that this only happens at the location 5838. All the messages after and before this are displayed correctly.

Any clue as to what's happening ?


Doesn't seem to be a problem related to this particular validator to me. Sounds more like a problem parsing the whole validation.xml file. Maybe the error message is broken just because it is in the middle of a reading buffer.

Something similar happened to me and it was an UTF-8 char in a non UTF-8 file. My advice is to check the whole file for possible parsing problems, after the location 5838 of course.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜