File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
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: 80
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: struts2: setting string value to int field of a bean does not throw any exception
 
Similar Threads
Error while validating the input
Avoiding Default primitive wrapper value display on JSF page
How OGNL automatically maps to the appropiate Object
Struts2 very simple validation doesn't work
why getters/setters in java