2010-10-21 37 views
1

我正在使用Spring 3.0.3 RestTemplate進行RESTful調用,以便在servicemix ESB中部署服務。 Service方法返回布爾值,並且無法在RestTemplate響應中接收此值。布爾返回類型不能與RestTemplate配合使用

String query = "?userId="+userId; 
RestTemplate rest = new RestTemplate(); 
Map<String, String> params = new HashMap<String, String>(); 

boolean status = rest.getForObject(SERVICE_URL+query,boolean.class,params); 

而且我得到以下錯誤

WARN : org.springframework.web.client.RestTemplate - GET request for "http://localhost:818 1/cxf/monitoring/logclear?userId=admin" resulted in 406 (Not Acceptable); invoking error handler org.springframework.web.client.HttpClientErrorException: 406 Not Acceptable at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultR esponseErrorHandler.java:69) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:486) 
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:443) 
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:409) 
    at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:206) 

任何幫助是極大的讚賞。謝謝!

+0

布爾是靈長類動物的類型,而不是一個類。你有沒有嘗試返回布爾(一個類)? – DwB 2010-10-21 15:02:22

+0

是的,我已經嘗試過,但沒有運氣 – ramrajedotcom 2010-10-21 23:55:53

回答

相關問題