First, Introduction
Description: The HTTP protocol transmits data without the concept of type, on the server side is the Request.getparameter (), Request.getparametervalue () method to get the request parameter to a String or string[] type.
However, this is inconvenient to use, we hope that the open source framework can automatically complete the type conversion, to use the direct access to the target type.
Second, Struts2 type conversion
1. STRUTS2 itself completes the automatic conversion of the string type to the basic data type, and other situations require us to define our own type converters. =
2. How to handle type conversion failure
(1) By default, STRUTS2 does not do any processing after a type conversion has failed.
(2) If the request parameter to the target basic type conversion error, the target base type is assigned the default value.
(3) If the request parameter to the target basic type wrapper class conversion error, the Target field will be assigned a value of NULL.
(4) If you want to be prompted in the event of an error, you need to have the target Action class implement the Com.opensymphony.xwork2.ValidationAware interface, which Actionsupport has been implemented for us.
Description: Com.opensymphony.xwork2.ValidationAware
3. Custom type Converters
4. Type conversion of complex type data
5. Type conversions in collection element objects
Type conversion of data of type 6.json
Not finished, to be continued.
Data type conversion of request parameter to presentation layer