Struts Save Object Date quote String type mismatch

Source: Internet
Author: User

First paste the exception keyword

[Com.opensymphony.xwork2.ognl.ognlvaluestack]-[warn] Error setting expression ' datetime ' with value ' [ ljava.lang.string;@74448287 ' for Object [email protected] [java.lang.NoSuchMethodException: Com.oss.Merchant.setDatetime ([Ljava.lang.String;)]
...

caused By:java.lang.NoSuchMethodException:com.oss.Merchant.setDatetime ([Ljava.lang.String;)
At OGNL. Ognlruntime.callappropriatemethod (ognlruntime.java:1246)
... 102 more
/--encapsulated exception------------\
Java.lang.NoSuchMethodException:com.oss.Merchant.setDatetime ([Ljava.lang.String;)

Describe the abnormal request again. Local, testing, formal three environments are no problem, foreign use can not be saved, view logs, found to report errors. So Baidu Google a few, there are the following explanations:

The YYYY-MM-DD format, which is not a standard time display format in foreign countries, struts interpretation is for input, which type is recently converted, such that the date of the format is mistaken for a string.

Online Professors ' solutions are:

1, build a conversion method, plus the configuration file, all the string to date are converted by this tool class.

2, the character encoding of the system from lang= "en_US". UTF-8 ", modified to: lang=" ZH_CN. UTF-8 "

3, also say with plug-in can, such as My97datepicker (my project itself is using this plugin, so I think this solution is not advisable)

4, on the JSP page with Java.util.Date first turn type (think it will not work)

Interested friends can try.

I chose the third workaround, defining a string datestr, receiving input from the form, and then

String Datestr;
New SimpleDateFormat ("Yyyy-mm-dd");D ate Date= sdf.parse (datestr); merchant.setdatetime (date);

This approach is simple, does not affect the global configuration, generally does not introduce new errors, that is, if the date input is more, it will cause a lot of duplicate code.

Struts Save Object Date quote String type mismatch

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.