Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.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启动控制器URL验证_Spring_Spring Boot_Spring Restcontroller - Fatal编程技术网

Spring启动控制器URL验证

Spring启动控制器URL验证,spring,spring-boot,spring-restcontroller,Spring,Spring Boot,Spring Restcontroller,我有一些Sprint控制器映射,如下所示 @GetMapping("/hello/{name}/age") private String hello(@PathVariable(value = "name", required = true) String name){ //... } @GetMapping("/hello/{name}") private String hello(@PathVariable(value = "name", re

我有一些Sprint控制器映射,如下所示

@GetMapping("/hello/{name}/age")
    private String hello(@PathVariable(value = "name", required = true) String name){
        //...
    }

   @GetMapping("/hello/{name}")
    private String hello(@PathVariable(value = "name", required = true) String name){
        //...
    }

    @GetMapping("/name")
    private ResponseEntity<?> queryPerson(@RequestParam(value = "query", required = false) String query) {
        // ...
    }
@GetMapping(“/hello/{name}/age”)
私有字符串hello(@PathVariable(value=“name”,required=true)字符串名){
//...
}
@GetMapping(“/hello/{name}”)
私有字符串hello(@PathVariable(value=“name”,required=true)字符串名){
//...
}
@GetMapping(“/name”)
private ResponseEntity queryPerson(@RequestParam(value=“query”,required=false)字符串查询){
// ...
}
但有一个客户体验来处理以下情况

当客户端发送/hello/john/age时,我应该返回与年龄相关的pojo,但当客户端调用/hello//age时,我必须返回400,用户名无效作为错误

由于我的代码是im,我已经有了其他映射hello/{name},所以它正在调用这个API并试图找到username='age',然后重试404


在这里,当用户调用/hello//age时,我可以使用400,那么如何在春季处理这个问题呢

将没有机会创建400

Tomcat正在折叠双斜杠: