Spring Boot URL长度验证

时间:2016-08-04 10:49:00

标签: java rest spring-mvc spring-security spring-boot

出于安全原因,如果URI请求长度大于400个字符,我需要返回1024错误。

有没有办法在Spring Boot中测试它?

目前我有一个简单的Controller对查询字符串和标题参数进行验证

@RestController
@Validated
public class myController {

    @RequestMapping(value = "{id}", method = GET)
    public SegmentationResponse getSegments(
            @PathVariable("id") @Valid @Size(min = 12) String id,
            @RequestHeader(value = "X-API-Key", required = true) @ValidAPIKey String apiKeyHeader,
            @RequestParam(value = "myParam", required = true) @Valid @Pattern(regexp = MY_REGEX) String myParam) {

        // DO Stuff
    }
}

所需

http://localhost:8080/<More than 1024 chars here>

返回400 Bad Request

0 个答案:

没有答案