aspose file tools
The moose likes Struts and the fly likes struts2: setting string value to int field of a bean does not throw any exception Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Struts
Reply Bookmark "struts2: setting string value to int field of a bean does not throw any exception" Watch "struts2: setting string value to int field of a bean does not throw any exception" New topic
Author

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

vikas byn
Ranch Hand

Joined: Mar 18, 2011
Posts: 64
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

Joined: Nov 17, 2011
Posts: 5
If I understand correctly the problem, use validation.

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

Tomas Bilek
 
 
subject: struts2: setting string value to int field of a bean does not throw any exception
 
Threads others viewed
why getters/setters in java
Avoiding Default primitive wrapper value display on JSF page
How OGNL automatically maps to the appropiate Object
Struts2 very simple validation doesn't work
Error while validating the input
developer file tools