STRUTS2 type converter, type conversion error, and input view

Source: Internet
Author: User

1.1.1 Type converters in Struts2

Struts2 built-in common data types a variety of converters

Boolean and Boolean

Char and Character

int and Integer

Long and long

float and float

Double and Double

Date can receive the YYYY-MM-DD format string

An array can convert more than one parameter of the same name into an array

Collection supports saving data to a List or Map collection

1.1.2 Error in type conversion in STRUTS2:

1.NoSuchMethodException Exceptions:

The background requires an int type to enter ABC in the page.

* reported an exception: Nosuchmethodexception (no exception for this method.)

* Normal input setage (int age);

* Enter a abc:setage (String age);---no way

String--->date. But the format of date must be YYYY-MM-DD not the date in this format, and an error will be added: nosuchmethodexception

2. You need to configure an input logical view:

* <result name= "input" >/demo3/demo1.jsp</result>

* Use <s:fielderror/>---in the page to get error messages in the Fielderror area. The page needs to enter the relevant tablib .... Uri= '/struts-tags ' profix= ' s '

3. Display Chinese information:

* Create a property file with the same name as the action class under the package that contains the action class.

* Customeraction.properties

* The key value of the property file: Invalid.fieldvalue. property name = Error message

STRUTS2 type converter, type conversion error, and input view

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.