简体   繁体   English

Spring Boot-忽略属性server.contextPath

[英]Spring Boot - ignore property server.contextPath

In my spring application.properties I've got property 在我的spring application.properties中,我有属性

server.contextPath=/my/context/path

But I need to setup controller that will handle this path: 但是我需要设置将处理此路径的控制器:

http:/localhost:8888/

Is there any way to ignore server.contextPath property only in one controller? 有什么方法只能在一个控制器中忽略server.contextPath属性吗?

Thanks 谢谢

No. 没有。

While using one DispatcherServlet you could remove the server.contextPath property and annotate all your controllers (but one) with @RequestMapping("/my/context/path") 使用一个DispatcherServlet您可以删除server.contextPath属性并使用@RequestMapping("/my/context/path")注释所有控制器(但一个@RequestMapping("/my/context/path")

Another options is to work with two DispatcherServlet s. 另一个选择是使用两个DispatcherServlet One mapped to /* containing the one controller and a second one mapped to /my/context/path/* containing all the other controllers. 一个映射到/*包含一个控制器,第二个映射到/my/context/path/*包含所有其他控制器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM