我正在使用路径变量,当我点击请求时,我收到了400错误请求
URL:http://localhost:8085/testing/v3/w200/http%3A%2F%2Fwww.bildarchivaustria.at%2FPreview%2F15620341.jpg
我不知道为什么它不起作用。我可能想念的很简单。请帮助
这是我的代码:
@RestController
@RequestMapping("/testing/v3")
public class ControllerV3
{
@GetMapping(value = "/{size}/{url}")
public ResponseEntity<byte[]> testByUrl(
@PathVariable(name="size", value="size" , required = false) String size,
@PathVariable("url") String url,
WebRequest webRequest, HttpServletResponse response) {
long startTime = 0;
if (LOG.isDebugEnabled()) {
startTime = System.nanoTime();
LOG.debug("url = {}, size = {}", url, size);
}
// i do other process here and return the image or video
}
}
答案 0 :(得分:1)
出于安全原因,Apache不允许将任何%2F
用作路径(find out more here)的一部分。
要使工作正常,请在您的URL中将所有%2F
替换为%252F
:
http://localhost:8085/testing/v3/w200/http%3A%252F%252Flocalhost%3A8080%252Ftesting%252Fv3%252Fw200%252Fhttp%3A%252F%252Fwww.bildarchivaustria.at%252FPreview%252F15620341.jpg
%2F
的编码为->%252F