Springmvc How to pass get date type data

Source: Internet
Author: User

Add the following code to the controller:

@InitBinder
public void Initbinder (Servletrequestdatabinder bin) {
SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");
Customdateeditor cust = new Customdateeditor (dsf,true);
Bin.registercustomeditor (Date.class,cust);
}
After this annotation, the string type of data passed by the front end can be automatically converted to date type data in the Controller method parameters:
@RequestMapping (value= "/index2")
public string Helloaction2 (date date) {//The parameter here automatically converts a string to a date type

Return "index";
}

This article is from the "11179738" blog, please be sure to keep this source http://11189738.blog.51cto.com/11179738/1744153

Springmvc How to pass get date type data

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.