2017-01-29 2 views
1

나는 쉬는 서비스를 통해 디렉토리 브라우징을 시도한다. 그것과 같이 정의는 : 내가 디렉토리와 같은 정의를 사용하는 경우특정 @RequestMapping에 대해 욕심 많은 @PathVariable을 활성화하는 방법은 무엇입니까?

@RequestMapping(path="ls/{path:.+}", method = RequestMethod.GET) 
public List<String> getDirectoryListing(@PathVariable("path") String path) throws IOException { 
    // ... 
} 

그러나, PathVariable {path:.+}는 문제를 소개합니다. 예를 들어,

$ curl http://localhost:8080/fileRepo/ls/dir/subdir 
             \___ ___/ 
              V 
              {path:.+} 

{ 
"timestamp":1485690489272, 
"status":404,"error":"Not Found", 
"message":"No message available", 
"path":"/dataset/ls/processed/dir1/subdir" 
} 

결과와 콘솔에 디버그 메시지를해야합니다

s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /files/ls/dir1/subdir 
s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/files/ls/dir1/subdir] 
o.s.w.s.handler.SimpleUrlHandlerMapping : Matching patterns for request [/files/ls/dir1/subdir] are [/**] 
o.s.w.s.handler.SimpleUrlHandlerMapping : URI Template variables for request [/files/ls/dir1/subdir] are {} 

겠어요 - RequestMappingHandlerMapping에 ls/{path:.+}이 모두 getDirectoryListing으로 해결되어야한다고 알리는 방법은 무엇입니까?

+1

'@ RequestParam'과 함께'/'를 포함하는 URL 만 전달할 수 있지만'@ PathVariable'이 아닌 URL을 전달할 수 없습니다. –

답변

-1

경로 변수에 "/"문자를 이스케이프해야하는 경로 변수에 dir/subdir을 보내는 경우. URL의 경로 변수 부분을 인코딩하고 을 디코드합니다.은 요청 처리기 수준에서 동일해야합니다.

+0

아니요, 인코딩 문제가 아닙니다. url 디코딩은 요청 매핑을 찾기 위해 url이 해결되기 전에 봄에 의해 투명하게 처리됩니다. – helt