Struts2 type conversion

Source: Internet
Author: User

Struts2 type conversion: (for the conversion between HTTP Request Parameters and Java strong types, you only need to name the HTTP parameter as a valid ognl expression, you can make full use of the struts2 type conversion mechanism.
If an unknown exception occurs during type conversion, struts2's conversionerror interceptor will automatically handle the exception and generate a prompt on the page)
Built-in type converter: (struts2 has built a built-in character string and a conversion converter between the following types)
> Boolean and Boolean
> Char and character
> Inthe and integer
> Long and long
> Float and float
> Double and double
> Date (the date format uses the short format of the local location where the user request is located)
> Array (by default, the array element is a string. If you provide a custom type converter, it is also an array of other composite types)
(Each element is converted separately based on the element type, but if the type of the array element itself cannot be converted, a type conversion error will occur)
> 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)

Ognl-based type conversion: (struts2 allows another simple method to convert request parameters to composite types)

Public class user {private string name; private string pass; // The setter and getter methods of the name and pass attributes ...} public class loginaction implements action {private user; // setter and getter methods of user public string execute () throws exception {...}}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.