spring-boot - Springboot中的GetMapping排除路径变量中的html文件
问题描述
我有一个带有以下 GetMapping 的控制器
@GetMapping(value = "/{path}")
public ResponseEntity searchAPI(@PathVariable("path") String API_NAME)
但我必须从这个 GetMapping 中排除 /index.html
我试过这样
@GetMapping(value = "/{path:^.*(?!index.html)}")
但这不起作用我需要单独编写每个 API 吗?请帮我
解决方案
点 (.) 是匹配任何符号的特殊字符,您需要使用反斜杠对其进行转义:
@GetMapping(value = "/{path:^(?!index\.html).*}")
推荐阅读
- angular - 如何防止输入字段接受 0 或 1 以外的其他数字?
- loops - 多像素搜索
- android - 使用 android 中的改造将 pdf / docx 文件(包括图像)上传到服务器
- ruby-on-rails - Masonry-Rails 排水沟打破布局
- android - 在 Android 中使用 ColorMatrix 使图像只有黑白
- r - 为值向量找到不同的区间,使每个区间中的值数大致相等
- amazon-web-services - AWS 无法访问 RDS 实例
- java - 致命异常:android.os.FileUriExposedException 帮助错误
- apache - 如何使 Docker apache2 虚拟主机工作
- php - 使用 php 从数据库中打印数据,该数据库在其列中有一项