2016-03-04 117 views

回答

4

使用形式編碼器假死:https://github.com/OpenFeign/feign-form和你的假死配置可以是這樣的:

class CoreFeignConfiguration { 

    @Autowired 
    private ObjectFactory<HttpMessageConverters> messageConverters 


    @Bean 
    @Primary 
    @Scope(SCOPE_PROTOTYPE) 
    Encoder feignFormEncoder() { 
     new FormEncoder(new SpringEncoder(this.messageConverters)) 
    } 
    } 

那麼客戶端可以這樣映射:

@FeignClient(name = 'client', url = 'localhost:9080', path ='/rest', configuration = CoreFeignConfiguration) 
interface CoreClient { 

    @RequestMapping(value = '/business', method = POST, consumes = MediaType.APPLICATION_FORM_URLENCODED) 
    @Headers('Content-Type: application/x-www-form-urlencoded') 
    void activate(Map<String, ?> formParams) 
} 
+0

照顧這條線'地圖 formParams',問號是必需的。 –

-1

請看看這個issue。看起來它包含了解決問題的方法。

+0

你的答案並沒有解釋如何發佈表單參數 – kazuar

+0

添加寫作時間(這是一年多前)沒有發佈FormEncoder的版本,並且唯一的解決方案在鏈接問題 –

+0

中描述的足夠公平,如果更新您的答案,我將能夠恢復投票 – kazuar