0
그래서 나는 보이는 봄 REST 애플리케이션을 쓴이 같은 비트 :필터가 호출되지 않습니다.
의 web.xml :
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>Archetype Created Web Application</display-name>
<filter>
<filter-name>CORSFilter</filter-name>
<filter-class>com.billboard.filters.SimpleCORSFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CORSFilter</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
MVC-디스패처-servlet.xml에 :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.billboard.imageService"/>
<mvc:annotation-driven/>
</beans>
및 컨트롤러 다음과 같습니다 : package com.billboard.imageService;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.billboard.rangeCache.Cache;
import com.billboard.rangeCache.CacheManager;
import com.billboard.rangeCache.ICache;
@Controller
public class ImageController {
@RequestMapping("/get")
public @ResponseBody String test() {
System.out.println("get images");
return "okay";
}
@RequestMapping("/getImages/{start}/{size}")
public @ResponseBody List<Image> getImages(@PathVariable String start, @PathVariable String size) {
System.out.println("get images");
ICache<Image> cache = CacheManager.getCache("imageCache");
return cache.get(Integer.parseInt(start), Integer.parseInt(size));
}
}
문제는 필터가 호출되지 않습니다. 내가 여기서 뭔가 잘못하고있는거야? Spring MVC는 컨테이너가 필터를 처리하는 방식을 방해합니까? (나는 그것을 매우 의심한다). 내가하려는 것은 REST 서비스가 COR (Cross origin requests)을 구현하는지 확인하는 것이다.