Jackson-core-asl-1.9.12.jar Jackson-mapper-asl-1.9.12.jar
The test is not for this error and does not have to rely on the two JARs.
The following configuration returns data normally
pom.xml
<!-- Jackson JSON Processor -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
For springMvc. In the XML
<mvc:annotation-driven>
<mvc:message-converters register-defaults="false">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=utf-8</value>
<value>text/xml;charset=utf-8</value>
<value>text/plain;</value>
<value>text/json;charset=utf-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
</mvc:message-converters>
</mvc:annotation-driven>
In the Controller
@RequestMapping(value = "checkLogin", method = RequestMethod.POST)
@ResponseBody
public ResultDto checkLogin(String name, String password, int role) {
return loginService.checkLogin(name, password, role);
}
——————————————————————————-
The ResultDTO object is missing some of the GET methods, causing an error in formatting the JSON object.
Remove the above two JARs and test with the GET method of the returned object, reporting 406 error code.
The debug code in ServletInvocableHandlerMethod. Catch exceptions in the class “Could not find acceptable representation.” ”
After adding the get method, the test returns the JSON character of the object normally
public class ResultDto {
private boolean succeed;
private Object data;
public ResultDto(boolean succeed) {
this.succeed = succeed;
}
public ResultDto(boolean succeed, Object data) {
this.succeed = succeed;
this.data = data;
}
/*
public boolean isSucceed() {
return succeed;
}
public Object getData() {
return data;
}
*/
public void setSucceed(boolean succeed) {
this.succeed = succeed;
}
public void setData(Object data) {
this.data = data;
}
}
Read More:
- The 406 status code can not find acceptable representation is returned in spring MVC
- Spring MVC error: could not find acceptable representation
- Spring MVC error HTTP status 400 – bad request
- Spring MVC – enable static resource access
- Spring MVC realizes page upload file
- Error 404 reported by spring MVC access Servlet
- When the spring MVC project is running on idea, an error is reported when the controller is a null pointer
- When docker starts tomcat, the access port of the container displays 404, and the source server fails to find the representation of the target resource or is unwilling to disclose an existing one
- Multithreading: when doing unit test, use thread pool to find that the specified code is not running and skip directly
- spring security There was an unexpected error (type=Forbidden, status=403).
- Springboot failed to parse MVC view
- JMeter running error response code: non HTTP response code: java.lang.illegalargumentexception find and solve
- Latex’s mathematical formula: derivation and representation of fraction
- Not registered via @EnableConfigurationProperties or marked as Spring component
- Gradle build spring boot failed to find plugins and reported an error
- NuxtSe rverError:Request failed With status code 500 my solution and thinking
- Error: request failed with status code 500
- IIS 7.5, ASP.NET MVC. HTTP error 500 (internal server error), but debugging does not enter the background, the browser only reports 500 errors
- Spring boot problem 1: error reporting life processing instructions for building a spring boot project
- Jenkins git configuration error status code 128 ‘text file busy’