Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 解析HTTP请求参数_Spring Boot_Rest_Http - Fatal编程技术网

Spring boot 解析HTTP请求参数

Spring boot 解析HTTP请求参数,spring-boot,rest,http,Spring Boot,Rest,Http,我想使用SpringBootRESTAPI将物理路径从文件服务器传递到web服务 我要发送的路径是 E:\\sharedFile\\data 我以@requirestParam的形式发送参数,如下所示 @PostMapping("/loadPicturesIntoDB") public ResponseEntity<String> loadDB(@RequestParam String path) { int size = imag

我想使用SpringBootRESTAPI将物理路径从文件服务器传递到web服务 我要发送的路径是 E:\\sharedFile\\data 我以@requirestParam的形式发送参数,如下所示

    @PostMapping("/loadPicturesIntoDB")
    public ResponseEntity<String> loadDB(@RequestParam String path) {
        int size = imageService.loadDB(path);
        return new ResponseEntity<String>("the database has been loaded with" + size + " files from the provided path ",
                HttpStatus.OK);
    }

提前感谢各位

在请求参数中发送URL会有问题,因为tomcat默认不执行编码

我建议您将此作为请求正文的一部分发送

2020-10-03 15:18:34.273  INFO 17356 --- [nio-8080-exec-1] o.apache.coyote.http11.Http11Processor   : Error parsing HTTP request header
Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.

java.lang.IllegalArgumentException: Invalid character found in the request target [image/loadPicturesIntoDB?path=%22E:\\sharedFile\\data%22]. The valid characters are defined in RFC 7230 and RFC 3986
   at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:486) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
   at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:261) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
   at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.38.jar:9.0.38]
   at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-embed-core-9.0.38.jar:9.0.38]
   at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) [tomcat-embed-core-9.0.38.jar:9.0.38]
   at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.38.jar:9.0.38]
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_231]
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_231]
   at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.38.jar:9.0.38]
   at java.lang.Thread.run(Thread.java:748) [na:1.8.0_231]