나는 파일 (이미지, PDF 파일 등 ,.) 역할을하는 컨트롤러가 있습니다스프링 MVC에서 Accept 헤더를 무시
: 내가 가진 파일을 요청하는 경우@Controller
public class FileController {
@ResponseBody
@RequestMapping("/{filename}")
public Object download(@PathVariable String filename) throws Exception {
returns MyFile.findFile(filename);
}
}
을 내가 406를 얻을 Accept 헤더를 다음
: 나는 Accept 헤더를 다음과 같은 파일을 요청하는 경우Request URL: http://localhost:8080/files/thmb_AA039258_204255d0.png Request Method:GET Status Code:406 Not Acceptable Request Headers Accept:*/*
나는 200 얻을
URL: http://localhost:8080/files/thmb_AA039258_204255d0.png Request Method: GET Status Code:200 OK Request Headers Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
이 내 스프링 MVC 컨텍스트에서 유일하게 뷰 리졸버 :
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" id="tilesViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
가 수락 헤더를 무시하는 스프링 MVC를 구성 할 수 어쨌든 있나요? ContentNegotiatingViewResolver를 사용하여이 작업을 수행하는 예제를 보았지만 xml 및 json을 처리하는 데만 사용되었습니다.
이것은 매우 비슷한 질문이지만 json의 경우 : http://stackoverflow.com/questions/5315288/spring-returning-json-with-responsebody-when-the-accept-header-is-throws-htt –