开发者

numeric validation in struts2

i want to validate textfield which sh开发者_运维问答ould allow only number 0-9 in any range how can i implement this


Struts2 ships with pretty good documentation. Learn how to use it :)

  1. Start here.
  2. There's chapter Validation.
  3. Check section Bundled Validators.
  4. You want to use int validation.


I'm not sure what you mean by "in any range". To do numeric validation you can use the int validator:

     <validator type="int">
          <param name="fieldName">myfield</param>
          <param name="min">0</param>
          <param name="max">9</param>
          <message>MyField needs to be between ${min} and ${max}</message>
      </validator>

I assume you just want integers and not real numbers.

This page describes all the validators that are available.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜