0

は、私は1つのFeignClientクラスを持っていると私はそれが動作しないコードの上に使用したとき、私はFeignClient APIクラスでmatrixvariableを使用するには?

@FeignClient(value = "apiService", url = "${api.url}", configuration =ApiServiceConfiguration.class) 
public interface ApiServiceFeign { 
    @RequestMapping(value = "/students{matrixParam}", method = RequestMethod.GET) 
    StudentList getStudents(@MatrixVariable("matrixParam") Map<String,List<String>>); 
} 

以下のようなパラメータ を渡すためにMatrixVariableを使いたいけど。ファインクライアントはMatrixVariableを理解できません。 この呼び出しを行う方法はありますか?いずれかがFeignclient

答えて

0

でMatrixVariableを使用して、より良い解決策を与える場合

現在、私は

@FeignClient(value = "apiService", url = "${api.url}", configuration =ApiServiceConfiguration.class) 
public interface ApiServiceFeign { 
    @RequestMapping(value = "/students;name={name};accountId={accountId}", method = RequestMethod.GET) 
    StudentList getStudents(@PathVariable("name") String name,@PathVariable("accountId") Long accountId); 
} 

以下のようなPathVariableを使用して一時的な解決策を見つけた私は本当にあなたが春にmatrix variables usageを有効にする必要があります感謝しています。それは以下のようにして行うことができます。行列変数の使用を可能にするために、あなたは偽にしRequestMappingHandlerMapping removeSemicolonContentプロパティを設定する必要があります

注意。デフォルトではtrueに設定されています。

MVC Java configとMVC名前空間の両方には、マトリックス変数の使用を有効にするためのオプションが用意されています。 Java configを使用している場合は、「MVC Java Configでの高度なカスタマイズ」セクションで、RequestMappingHandlerMappingのカスタマイズ方法について説明します。

MVC名前空間では、要素にはenable-matrix-variables属性があり、trueに設定する必要があります。デフォルトではfalseに設定されています。

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc.xsd"> 

    <mvc:annotation-driven enable-matrix-variables="true"/> 

</beans> 
関連する問題