For most common types, developers do not need to care about type conversion. Struts 2 can complete most common type conversion tasks. These common types are converted using the built-in type converter of Struts 2. Struts 2 has built in the conversion between the string type and the following types.
Boolean and Boolean: converts the string and boolean values.
Ø char and Character: converts strings and characters.
Int and Integer: converts the string and Integer values.
Ø long and Long: converts string and long integer values.
Ø float and Float: converts a string to a single-precision floating point value.
Ø double and Double: Convert the string and double-precision floating point values.
Ø Date: converts string and Date types. The Date format uses the SHORT format of the Locale where the user request is located.
Ø array: by default, the array element is a string. If you provide a custom type converter, it can also be an array of other composite types.
Ø set: by default, it is assumed that the element type of the set is String and a new ArrayList is created to encapsulate all strings.
For array type conversion, each element is converted separately according to the type of array elements. However, if the type conversion of array elements cannot be completed, the system will encounter a type conversion error.
Because Struts 2 provides the above types of converters, if you need to convert HTTP request parameters to the above types, you do not need to perform any special processing. Therefore, in most actual development, developers do not need to convert their own types.
This article from the "crazy Java Li Gang" blog, please be sure to keep this source http://javaligang.blog.51cto.com/5026500/871582