• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts2: setting string value to int field of a bean does not throw any exception

 
vikas byn
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a jsp which has a field user age.
age: <s:textfield name="user.age" id="user.age" ></s:textfield>

in action class, i have i create user bean getter and setter.

it works fine if i enter age as integer but if i enter string for age then it does not throw any exception.

where is the problem?
 
Tomas Bilek
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand correctly the problem, use validation.

http://struts.apache.org/2.x/docs/validation.html

Tomas Bilek
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic