【发布时间】:2018-06-19 19:38:20
【问题描述】:
我使用Spring Boot,我的主控制器处理所有顶级网址:
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class IndexController {
@GetMapping({"/*"})
public ResponseEntity<String> handleIndex() {
// ...
}
}
由于某些原因,我希望从处理我的控制器中排除路径 /exclude_path。
类似这样的:
@GetMapping(include={"/*"}, exclude={"/exclude_path"})
你能回答我怎么做吗?
【问题讨论】:
-
如果你不把它放在GetMapping里面是不会被处理的。不知道这里有什么问题。
-
@pvpkiran,我的路径中有通配符
/*,并且只想排除一个映射到该通配符的 url (/exclude_path)。 -
只需为该特定处理添加另一个映射,例如“AcccessNotAllowed”或 404NotFound 之类的东西。
标签: java spring spring-mvc spring-boot