server.servlet.contextPath 和 spring.mvc.servlet.path 对比

@RestController
@RequestMapping("/v1")
class Controller {

}

更通用的方法

spring.mvc.servlet.path=/v1

或者

server.servlet.contextPath=/v1

上下文路径是用来访问web应用程序的名称。它是应用程序的根,默认情况下,Spring Boot提供根上下文路径(“/”)上的内容。可以使用属性server.servlet.context-path更改此上下文路径。

另一方面,servlet路径表示主DispatcherServlet的路径。默认值类似于上下文路径,即(“/”),可以通过配置不同的spring.mvc.servlet.path属性进行更改。假设servlet属于servlet上下文,更改上下文路径也会影响servlet路径。

如果您具有以下配置,请记住这两条信息:

server.servlet.context-path=/context-path
spring.mvc.servlet.path=/servlet-path

然后应用程序servlet路径将变为http://localhost:8080/context-path/servlet-path。

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值