0
我正在開發Spring MVC應用程序。此應用程序期望客戶端在請求正文中發送XML。我怎樣才能從正文中提取這個XML,然後創建一個DOM對象? 我使用Spring 3.0Spring MVC流程發佈數據
由於 阿迪
我正在開發Spring MVC應用程序。此應用程序期望客戶端在請求正文中發送XML。我怎樣才能從正文中提取這個XML,然後創建一個DOM對象? 我使用Spring 3.0Spring MVC流程發佈數據
由於 阿迪
的@RequestBody方法參數註釋指示的方法 參數應綁定到HTTP請求正文的值。對於 例如:
@RequestMapping(value = "/something", method = RequestMethod.PUT) public void handle(@RequestBody String body, Writer writer) throws IOException writer.write(body); }
通過使用一個 HttpMessageConverter請求體轉換爲方法參數。 HttpMessageConverter負責將 從HTTP請求消息轉換爲對象並將 從對象轉換爲HTTP響應正文。該 RequestMappingHandlerAdapter支持與 的@RequestBody註釋以下默認HttpMessageConverters:
ByteArrayHttpMessageConverter converts byte arrays. StringHttpMessageConverter converts strings. FormHttpMessageConverter converts form data to/from a MultiValueMap<String, String>. SourceHttpMessageConverter converts to/from a javax.xml.transform.Source.
所以身體參數將包含XML?我可以使用SourceHttpMessageConverter來獲取DOM嗎? – adi 2012-03-04 15:52:30