=10;$.post (home+ "/user/queryallinfo", param,function (Result) {if (Result!=null result.success) {var obj =result.rows;for (var i = 0; i The discovery did not appear before the uncaught referenceerror: $ is not defined error, but prompted 406 (not acceptable), Baidu after the 406 (not acceptable) to know The word used the @responsebody in controller control layer., to convert the object to JSON format, missing the conversion dependent jar package, and later added
, because jackson also provides a complete serialization solution for this, we only need to introduce jackson-datatype-jsr310 dependencies in pom. xml, as shown below:
Note: you do not need to specify a specific version when setting the spring boot parent. You are not recommended to specify a specific version.
This module encapsulates the implementation of Java 8 time-date API serialization. The specific i
directory, when connecting to the DFS error will occur, the prompt message is: "error: failure to login. the pop-up error prompt box is "An internal error occurred during:" Connecting to DFS hadoop ". org/apache/commons/configuration/Configuration ". check the log of Eclipse and find that the jar package is missing. Further find the information, found that directly copy the hadoop-eclipse-plugin-0.20.203.0.jar, the lib directory of the package is missing jar package.
After collecting online inf
) { User user = Userservice.login (username, password) ; return user; }Here I use the Jackson Bag:(1) Jackson-core 2.5.0(2) Jackson-databind 2.5.0(3) Jackson-annotations 2.5.0After importing build path;Warning: If you use an ORM tool such as hibernate to generate a Pojo class, one-to-one, a multi-level
dependencies and other dependencies are not shown):Dependency>Groupid>org.codehaus.jacksonGroupid>Artifactid>jackson-core-aslartifactid> version>1.9.13version>dependency>dependency> groupid>org.codehaus.jacksongroupid> artifactid> Jackson-mapper-aslartifactid> version>1.9.13version> DEPENDENCY> This dependency is a dependency of JSON serialization.Ok. We add a method to the controller:@RequestMappi
(xmlstreamexception E1) {e1.printstacktrace ();} If (reader! = NULL) {try {reader. Close () ;}catch (xmlstreamexception e) {e. printstacktrace ();}}}}
2, Jackson
Jackson can provide flexible conversion policies, for example, whether to recognize the root attribute as the object type during the conversion (jettison will, JSON-lib won't, Jackson won't by def
.
Supplement:
What is TypeToken?
The use of TypeToken is very simple.Generic type to be retrievedConstruct an anonymous subclass as a generic parameter of TypeToken, and you can use the getType () method to obtain the generic parameter type of the generic class we use.
Iii. Use Jackson
Third-party tools know how to deal with it, jar package: http://wiki.fasterxml.com/JacksonDownload
Here, you need to use:
Jackson
Configure Hive: https://cwiki.apache.org/confluence/display/Hive/GettingStarted on hadoop 0.20
After the configuration is complete, run bin/hive under $ hive_home and the nosuchfielderror: allow_unquoted_control_chars error is displayed.
I checked the information online and found that the hadoop Jackson package is older than the hive Jackson package.
The solution is$ Hive_home/lib/
What is JSON
JSON (JavaScript Object Notation) is a lightweight data exchange format. Easy to read and write. It is also easy to parse and generate machines. It is based on a subset of JavaScript programming language, standard ECMA-262 3rd edition-December 1999. JSON uses a completely language-independent text format, but it also uses a habit similar to the C language family (including C, C ++, C #, Java, JavaScript, Perl, Python, and so on ). These features make JSON an ideal data exchange lang
Json-lib
Json-lib is a Java class library (official website: http://json-lib.sourceforge.net/) to achieve the following functions:
Convert JavaBeans, maps, collections, Java arrays, and XML into JSON format data
Convert JSON format data to a JavaBeans object
Json-lib Required JAR Package
Commons-beanutils-1.8.3.jar
Commons-collections-3.2.1.jar
Commons-lang-2.6.jar
Commons-logging-1.1.1.jar
Ezmorph-1.0.6.jar
Json-lib-2.4-jdk15.jar
variables, but also to the outer function ' s parameters. Note that the inner function cannot call the outer function ' s arguments object, however, even though it can call The outer function ' s parameters directly.You create a closure by adding a function inside another function.A Basic Example of Closures in JavaScript:?1 functionShowName (FirstName, lastName) {?2?varNameintro = "Your name is";3 //This inner function have access to the outer function ' s variables, including the paramete
component (component).2, HttpmessageconvertersThe SPRINGMVC uses the Httpmessageconverter interface to convert HTTP request and response. objects are automatically converted to JSON (using Jackson), or XML (with Jackson XML or JAXB). Strings are usually UTF-8 encoded by default.Importorg.springframework.boot.autoconfigure.web.HttpMessageConverters;Importorg.springframework.context.annotation.*;ImportOrg.sp
1, Spring boot and cloud build microservices, return data from JSON into XMLProblem: The Spingboot item itself is annotated with @restcontroller, and the return result is also in JSON format, but the XML format returned by both the consumer and the provider after the Eureka of the Springcloud is built. The produces= "Application/json" must be added to the provider-consumer approach, but is it useless to @restcontroller the integrated @responsebody in the annotation itself?Solution: Remove this
="org.format.demo.controller"/>The following dependencies are required in the POM (Spring dependencies and other dependencies are not shown):Dependency>Groupid>org.codehaus.jacksonGroupid>Artifactid>jackson-core-aslartifactid> version>1.9.13version>dependency>dependency> groupid>org.codehaus.jacksongroupid> artifactid> Jackson-mapper-aslartifactid> version>1.9.13version> DEPENDENCY> This dependency
String System.out.println ( "-----returned JSON =" + responsestring); }}Back to top 3 JUnit test
The database tables tested are as follows:
Test 1: Parameters (HttpServletRequest Request,model Model)
Test 2: Parameters (User U,model Model)
Back to top 4 several jar packagesMany problems come from the fact that there are few jar packages.Here are the Maven dependencies for several jar packages:Code Listing 4-1:pom.xml (partial) Dependency>Groupi
The following code wants to convert a Java object into a JSON object via Jackson.
Objectmapper objectmapper = new Objectmapper ();
Objectmapper.enable (serializationfeature.wrap_root_value);
Objectmapper.setserializationinclusion (include.non_null);
Objectmapper.setserializationinclusion (include.non_empty);
String str = objectmapper.writevalueasstring (auth);
But in objectmapper.writevalueasstring () This place, Eclipse reported the type com.fast
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.