Ok, RESTful JSON을 제공하는 Spring 3.2 프로젝트에서 작업하고 있습니다.Spring 3.2 애플리케이션이 JSON 서비스를 제공하지 않아 406 오류가 발생했습니다.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>saltCityWifi</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/servlet-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>saltCityWifi</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<display-name>Salt City Wifi</display-name>
</web-app>
이 서블릿-config.xml 파일 :
나는이 web.xml을 가지고
package com.saltcitywifi.controller;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.saltcitywifi.model.HotSpot;
import com.saltcitywifi.service.HotSpotService;
import com.saltcitywifi.service.HotSpotServiceImpl;
@Controller
public class HotSpotController {
@RequestMapping(value="/hotSpot", method = RequestMethod.GET)
public @ResponseBody List<HotSpot> getHotSpots() {
HotSpotService hotSpotService = new HotSpotServiceImpl();
List<HotSpot> spots = hotSpotService.getAllHotSpots();
return spots;
}
}
모든 것이 잘 작업했다 : 여기
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<context:component-scan base-package="com.saltcitywifi" />
<mvc:annotation-driven />
</beans>
나의 컨트롤러 금요일에이 프로젝트에 대해 조금 배우려고 갑자기 406 오류가 발생했습니다. "thi가 식별 한 자원 요청은 "요청" "헤더"에 따라 수용 할 수없는 특성을 가진 응답 만 생성 할 수 있습니다. "
필자는 어떤 이유로 Jackson Jackson 종속성이 더 이상 내 빌드 경로에 포함되어 있지 않다고 생각합니다. 그러나 빌드 경로 구성을 클릭하면 Maven 종속성 폴더 내부에 jar 파일이 표시됩니다.
위와 관련한 도움을 주시면 대단히 감사하겠습니다. 프로젝트 정리/업데이트를 시도하고이 비슷한 문제를 골라서 읽으십시오.