帮助 - 我还能做些什么来解决这个错误?org.springframework.web.HttpMediaTypeNotAcceptableException ::无法找到可接受的表示.
我认为我的项目已正确配置以处理json restful请求.在过去的几天里,我已阅读并应用各种建议无济于事.关于我应该采取哪些不同的做法,还有其他想法吗?
我使用的是Spring MVC 4.1.5和com.fasterxml 2.5.1.
我的pom.xml的一部分
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.5.1</version>
<type>bundle</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.5.1</version>
<type>bundle</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.1</version>
<type>bundle</type>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这是我的web.xml的一部分
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/appServlet/servlet-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
这是我的servlet-context.xml的一部分
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<!-- Handles HTTP …Run Code Online (Sandbox Code Playgroud) 我想在浏览器中显示控制器返回的 ResponseEntity 的主体(使用 Spring):
return new ResponseEntity<>(l.getReachableDate(), HttpStatus.NOT_FOUND);
l.getReachableDate()返回一个 Date 类型,我想以如下方式显示它:
<header>
<h1><span>Url is not reachable from</span> <!-- body --> </h1>
</header>
Run Code Online (Sandbox Code Playgroud)
我怎样才能让它显示出来?