Http://www.cnblogs.com/lxsweat/p/4372508.htmlon the CodeThe use method and the UserInfo entity object are not affixed to the code. //////////// object /// json string public static string Serializetojson (object data" {return Get Results (red font) var data ={"dbstring": "Test", "Modeluserinfo": {"user_id": 1002, "user_name": "[email protected]", "Real_name": "[email protected]", "Password": "96e79218965eb72c92a549dd5a330112", "Mobile": "13121893780", "Lng": 117.19381, "Precision": 0, "la
Defaultdatetimeformat = "yyyy '-' mm '-' dd ' T ' HH ': ' mm ': ' SS. Fffffffk "causes, and it also provides the property" DateTimeFormat "to modify the date style, as long as we write in this format OK. Staff Jack = new Staff {Name = ' jack ', age = $, Gender = ' Male ', departmentname = ' personnel Department ', BirthDate = new DateTime (1982,2,12), employmentdate = new DateTime (2010,12,12)}; Isodatetimeconvert
Defines a static class in which static methods are defined, and method extensions to parameter types are implemented by adding the This modifier to the parameter types in the methodsExamples such as namespace Demo{ //The class here must be a static class Public Static classJson {//method is a static methodThe //This modifier is followed by a string type that extends the Tojson method for the string type Public Static ObjectToJson ( This stringJson) { returnJson = =NULL?NULL: Jsoncon
construction Method test ()//execute Test (), and then execute Test (string text) public test (string text): the This () { Console.writ Eline (text); Console.WriteLine ("Parametric constructor");} } Class program { static void Main (string[] args) { try { Test test = new Test ("Zhang San"); } catch (Exception ex) { Console.WriteLine (ex); }
-BackColor = "# eeeeeeee"DayHeaderStyle-ForeColor = "# ffffff"SelectionMode = "None"TodayDayStyle-BorderColor = "# 5e715e"TodayDayStyle-BorderWidth = "1"TodayDayStyle-Font-Bold = "true"TodayDayStyle-ForeColor = "# 5e715e"/>
The second step is to adjust the internal functions. This work is mainly focused on the handling of the following events.
The Code is as follows:
Copy code
PreRender: occurs when the server control is to be rendered to the Page object it contain
When using the JSON method to return data, if there is a time format, it will become "\/date (1369419656217) \/", and asked my colleagues to find a solution
UsingNewtonsoft. JSON;UsingNewtonsoft. JSON. converters;VaRTimeconverter =NewIsodatetimeconverter {datetimeformat ="Yyyy-mm-dd hh: mm: SS"};ReturnContent (jsonconvert. serializeobject (data, formatting. indented, timeconverter ));
We encapsulate this method, write it to the controller base cla
The key code is marked in red:
Public class test: system. Web. UI. Page
{
Protected system. Web. UI. webcontrols. Calendar calendar1;
Private system. Threading. thread t;
Private cultureinfo oldculture;
Private void page_load (Object sender, system. eventargs E)
{
// Place user code here to initialize the page
}
# Code generated by region web Form Designer
Override protected void oninit (eventargs E)
{
//
// Codegen: This call is required by the ASP. NET web form designer.
/
. Read more about SQLite in-memoryDatabases here.
Data Source =
: Memory: ;
Version =
3 ;
New =
True ; Using UTF16
Data Source =
C: \ mydb. DB ;
Version =
3 ;
Useutf16encoding =
True ; With Password
Data Source =
C: \ mydb. DB ;
Version =
3 ;
Password =
Mypassword ; Using the pre 3.3x database format
Data Source =
C: \ mydb. DB ;
Version =
3 ;
Legacy format =
True ; With Connection Pooling
Connection pooling is not enabled by default. Use the following parametersControl
IsoDateTimeConverter ();// The Custom date format is used here. If this format is not used, the default format is ISO8601.TimeConverter. DateTimeFormat = "yyyy '-'mm'-'dd''' HH': 'mm': 'ss ";String output = JsonConvert. SerializeObject (m, Newtonsoft. Json. Formatting. Indented, timeConverter );
By the way, javascript has a natural processing capability for json-format data and is very compatible with json-format data.
For example:
Function pppp (){V
. xxx to obtain the value.
When processing datetime format, JsonConvert returns an absolute value similar to 1198908717056. Therefore, when processing datetime, perform a conversion. The statement is as follows:
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter ();
// The Custom date format is used here. If this format is not used, the default format is ISO8601.
TimeConverter. DateTimeFormat = "yyyy '-'mm'-'dd''' HH': 'mm': 'ss ";
String
Before looking at this article, I hope you know something about the formatter mechanism of SPRING3, and you can poke at it without knowing it.There are two levels of formatting in Spring3, one for type-level formatting and the other for field formatting.First, for type-level formatting that is, for example, for the date type, I use a format scheme, which can be registered as follows:Conversionservice.addformatter (New formatterFor field-level formatting, it is relatively flexible and is a scheme
= birth;
}
@Override public
String toString () {return
"User [id= + ID +", name= "+ name +", birth= "+ birth +]";
}
private int id;
@NotEmpty
private String name;
@Past
@DateTimeFormat (pattern= "YYYY-MM-DD")
private Date birth;
}
PS: @Past indicates that time must be a past value
3. Use SPRINGMVC form form in JSP
Ps:path corresponds to name
Code in 4.Controller
@Controller
@RequestMapping ("/form") publi
checkbox)
equals
Validate[equals[id]]
The current control value needs to be the same as the value of the ID control
Phone
Validate[custom[phone]]
Verifying phone numbers
Email
Validate[custom[email]]
Verify Email Address
Integer
Validate[custom[integer]]
validating integers
Number
Validate[custom[number]]
Verifying numbers
Date
Validate[custom[date]]
Validation date, in the fo
); } } } /*** Format The Date as String, using the specified DateFormat. */@Override PublicString Getastext () {Date value=(Date) getValue (); DateFormat DateFormat= This. DateFormat; if(DateFormat = =NULL) DateFormat=TimeFormat; return(Value! =NULL? Dateformat.format (value): ""); }}The second is how the annotations are made:Import Org.springframework.format.annotation.DateTimeFormat; /** * Check- in date * * @DateTimeFormat
@requestmapping, @ExceptionHandler, to process the request.It also enables the following:
Spring 3 Style type conversion-with a Conversionservice instance mated to JavaBean propertyeditors for data Binding.
Supports @numberformat annotations to format the number field through Conversionservice.
Supports the use of @datetimeformat annotations to format the date, Calendar, Long, and Joda time fields.
Support for using @valid checks
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.