0
我正在寫一個Controller
,以取代舊系統供應的XML文檔下的Spring Web控制器返回XML - 但是URL有.html
擴展.html擴展
我的控制器看起來像這樣
@RequestMapping(value="/{name}.html",
method = RequestMethod.GET,
consumes = MediaType.ALL_VALUE,
produces = MediaType.APPLICATION_XML_VALUE)
public @ResponseBody XmlContent getContent(@PathVariable(value = "name") String name) {
return service.getXmlContent();
}
當我試着打了URL,我得到一個406錯誤:
The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.
如果我改變了請求映射爲.xml
這一切工作正常。是否有我需要禁用的組件 - 攔截請求的.html
部分並拒絕將其映射到xml的東西?