and provides: Data binding support, @NumberFormatannotation support, @DateTimeFormat support, @Valid support, read/write XML support (JAXB), read/write JSON support (Jackson).
Later, we used the JSON support when we processed the response to the AJAX request.
Later, when you write JUnit unit tests on an action, you take defaultannotationhandlermapping and annotationmethodhandleradapter two beans from the spring IOC container, To complete the test, tak
and provides: Data binding support, @NumberFormatannotation support, @DateTimeFormat support, @Valid support, read/write XML support (JAXB), read/write JSON support (Jackson).Later, we used the JSON support when we processed the response to the AJAX request.Later, when you write JUnit unit tests on an action, you take defaultannotationhandlermapping and annotationmethodhandleradapter two beans from the spring IOC container, To complete the test, take
:" + reader["name"] + "\tscore:" + reader["score"]);
Console.ReadLine ();
}
}
} Eg:: #region SQLite operation (check if database and table exist, create if not present) If the database does not exist, create the database MyDatabaseif (! File.exists ("Mydatabase.sqlite")) Sqliteconnection.createfile ("Mydatabase.sqlite"); To create a connection to a database MyDatabaseSqlitehelper _sqlitehelper = new Sqlitehelper ("Data source=mydatabase.sqlite; Version=3;
resource, the Dispatcherservlet Continue ProcessingMvc:annotation-drivenis automatically registeredRequestmappinghandlermappingRequestmappinghandleradapterExceptionhandlerexceptionresolver of three beans. You can access static resources.1.6. Mvc:annotation-drivenand theMvc:default-servlet-handlerAdd mvc:annotation-driven when configuring the SPRINGMVC configuration filewill automatically register three beans2 requestmappinghandlermapping2 Requestmappinghandleradapter2 Exceptionhandlerexceptionr
Resolve http400 ErrorsThere are usually two sources:A string is passed in the drop-down list on page 1, and the server requires an integer type, so the server rejects it.2, the browser to the server side of the date format string, the server can not understand, so need to be on the entity's date type member variable on the @datetimeformat (pattern = "YYYY-MM-DD")Server-Browser encapsulated JSON http://jadethao.iteye.com/blog/1741162Browser--Server con
format, the solution is to format the DateTime type to the string type and then serialize it. If you do not want to modify the code, you can use the following solution.
Json. Net provides the IsoDateTimeConverter date conversion class, which can be implemented through JsnConverter
[JsonConverter(typeof(IsoDateTimeConverter))] public DateTime Birthday { get; set; }
However, the IsoDateTimeConverter date format is not what we want. We can inherit this class to implement our own date
pu
processing For the Dateime type date format is more troublesome, the system will be formatted into the ISO date standard, but the actual use of most of the use of the process may be yyyy-mm-dd or YYYY-MM-DD HH:mm:ss Two formats of the date, The workaround is to change the datetime type to a string type itself, and then serialize it. If you do not want to modify the code, you can implement the following scenario.Json.NET provides a isodatetimeconverter date conversion class that can be jsnconver
the inherited JavaScriptConverter method, which is specifically mentioned in the following deserialization.Json.NET the date generated by default is also inconvenient for the client to read and needs to be handled simply:String newtonstr = Jsonconvert.serializeobject (p, formatting.indented, new Isodatetimeconverter () { DateTimeFormat = "Yyyy-mm-dd HH:mm:ss"});2, JavaScriptSerializer serialization will be special characters (such as A
IsoDateTimeConverter { DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss", DateTimeStyles = DateTimeStyles.AdjustToUniversal };var postData = JsonConvert.SerializeObject(ent, Newtonsoft.Json.Formatting.Indented, timeConverter);
Finally, I felt that some language features of Java 8 were added, such as Lambda expressions, Optional classes, Stream APIs, default methods, and method references. NET, developing Java applications is also quite
, sortable: true },{Title: 'modification time', field: 'modifiedon', width: 140, sortable: true}], (4) Finally, let's take a look at what we thought after the conversion:. The background uses the base class to solve the problem. (1) The first method is mentioned above, so now we are talking about the second method. The second method is shown in the title, we use the background base class to achieve this effect, so we know that we have established a BaseController base repository in our previous
process may be yyyy-mm-dd or YYYY-MM-DD HH:mm:ss Two formats of the date, The workaround is to change the datetime type to a string type itself, and then serialize it. If you do not want to modify the code, you can implement the following scenario.Json.NET provides a isodatetimeconverter date conversion class that can be jsnconverter to achieve the appropriate date conversion [Jsonconverter (typeof(Isodatetimeconverter))] Public Get set; }But the Isodatetimeconverter date format is not
. There are, for example:Seamless support of the JSR-303 validation framework (validation metadata through @valid annotation definitions);Type conversion (PropertyEditor is still in effect) using Conversionservice starting with Spring 3, supporting the use of @numberformat and @DateTimeFormat for formatting numbers and dates;Httpmessageconverter (HTTP input/output converters, such as JSON, XML, and other data-output converters);Contentnegotiatingviewr
System.out.println (User.tostring ()); System.out.println (DD); return "index"; }16}Above, problem solved. Then we switch the second way, delete the Basecontroller class, add annotations directly to the CreateDate field in the user entity class, and note the 10th line of code: 1 Import java.util.Date; 2 3 Import Org.springframework.format.annotation.DateTimeFormat; 4 5 public class User {6 7 private int userId; 8 private String UserName; 9 @
About the resolution of the SPRINGMVC date problem in addition to this blog, "SPRINGMVC date format data transfer resolution @DateTimeFormat use and Configuration" article,There are also the following ways:Add this code to the controller:1 @InitBinder2 Public voidInitbinder (Servletrequestdatabinder binder) {3 /**4 * field format for automatic conversion of date types5 */6SimpleDateFormat SDF =NewSimpleDateFormat ("Yyyy-mm-dd");7
format, this kind of formatting looks a bit uncomfortable, if it is "2016-03-25 17:19:17" feel better.Resolved as follows:In solving the second problem, our new class Underlinesplitcontractresolver overrides the Createproperties method:Resolves API NULL and time format issues protected override ilist . Select (p = = { var jp = base. CreateProperty (P, memberserialization); if (JP. PropertyType = = typeof (System.String)) JP. Valu
() or float. ToString () method for invariant or English culture.[C #]DataView. rowFilter = "Year = 2008" // integer value dataView. rowFilter = "Price = 1199.9" // float value dataView. rowFilter = String. format (CultureInfo. invariantCulture. numberFormat, "Price = {0}", 1199.9f );Date values are enclosed within sharp characters #. The date format is the same as is the result of DateTime. ToString () method for invariant or English culture.[C #]DataView. rowFilter = "Date = #12/31/2008 #" //
Previous projects have been encountered with a database with datetime type data returned to the foreground will become a timestampIt's obviously not what we want.So I was in the original project selected in the front-end JS format date (XXXX) Form of processing now I want to be a little stupidToday brainwave thought that it would be possible to turn the DateTime into a string on the server to return to the result with this articleService side:1Datagetentities context =Newdatagetentities ();2
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.