使用spring-mvc註釋,我如何定義可以POST form-url-encoded的@FeignClient?如何使用Spring Cloud Feign POST POST form-url-encoded數據
3
A
回答
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)
}
-1
相關問題
- 1. 如何微調Spring Cloud Feign客戶端?
- 2. Spring-cloud feign文件上傳
- 3. 如何在Feign-Client中設置HostnameVerifier從spring-cloud-netflix-feign
- 4. 如何使用swagger-codegen-maven-plugin生成spring cloud feign客戶端
- 5. netflix feign POST請求問題
- 6. Android Retrofit 2使POST請求多個參數(沒有FormUrlEncoded)
- 7. Spring Cloud config feign fallback(CircuitBreaker)規則
- 8. 使用drakma POST POST JSON數據:http-request
- 9. 如何在@Field和@FormUrlEncoded中使用@Body?
- 10. 當http代碼爲401時,使用spring cloud feign,respose.body()爲null
- 11. 如何使用LWP發送POST數據?
- 12. 如何使用curl POST XML數據
- 13. Spring MVC RestTemplate POST使用JSON
- 14. 使用Spring獲取POST參數
- 15. 如何使用RestTemplate POST POST XML
- 16. 使用HttpUrlConnection POST joson數據
- 17. Python POST數據使用mod_wsgi
- 18. 使用PHP $ _ POST數據
- 19. Django使用jquery POST數據
- 20. 如何使用VBScript POST POST HTTPS請求
- 21. Spring MVC的使用jQuery POST調用
- 22. Spring cloud Feign OAuth2請求攔截器不起作用
- 23. PHP - 用POST數據
- 24. LswApiCallerBundle POST數據
- 25. 使用jquery POST POST表單
- 26. 使用Spring Cloud設置數據源
- 27. 如何使用$ .post與Django?
- 28. Spring-portlet POST ajax xmlHttpRequest
- 29. 如何使用POST方法
- 30. jQuery Autocompleter如何使用POST?
照顧這條線'地圖 formParams',問號是必需的。 –