This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


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
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: struts2: setting string value to int field of a bean does not throw any exception
 
It's not a secret anymore!