Struts 2 验证中的奇怪行为
我有一个 Struts 2 应用程序,验证工作正常,它验证必要的字段并抛出足够的错误消息。问题出现在一个非常具体的位置,即字符号 5838!
在我的validation.xml 文件中,我定义了许多字段,其中之一是
<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 enter your State."
从技术上讲,我应该得到关于我只得到的娱乐的
"Please enter yo".
,这发生在位置 5838(即错误消息截断)。
现在,如果我在标签中添加一个空格,
"Please enter y".
我注意到这只发生在位置 5838。在此之后和之前的所有消息都会正确显示。
关于发生什么事的任何线索吗?
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 formatting !)
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说,这似乎不是与这个特定验证器相关的问题。听起来更像是解析整个validation.xml 文件时出现的问题。也许错误消息被破坏只是因为它位于读取缓冲区的中间。
类似的事情也发生在我身上,它是非 UTF-8 文件中的 UTF-8 字符。
我的建议是检查整个文件是否存在可能的解析问题,当然是在位置 5838 之后。
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.