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를 사용하고 싶습니다. Feign 클라이언트가 MatrixVariable을 이해할 수 없습니다. 전화를 걸 수있는 방법이 있습니까?

현재, 나는 어떤 사람이 당신은 봄에 matrix variables usage를 사용하도록 설정해야합니다 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를 사용하여 임시 해결책을 발견했다. 그것은 다음과 같이 할 수 있습니다. 행렬 변수의 사용을 가능하게

주, 당신은 거짓에을 RequestMappingHandlerMapping removeSemicolonContent 속성을 설정해야합니다. 기본적으로 true로 설정됩니다.

MVC Java config 및 MVC 네임 스페이스는 모두 행렬 변수 사용을위한 옵션을 제공합니다. Java 구성을 사용하는 경우 MVC Java 구성의 고급 사용자 정의 섹션에서는 RequestMappingHandlerMapping을 사용자 정의하는 방법에 대해 설명합니다.

MVC 네임 스페이스에서 요소에는 true로 설정되어야하는 enable-matrix-variables 특성이 있습니다. 기본적으로 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>