SpringBoot2.0给所有Controller添加统一前缀

需求

  给所有Controller添加统一前缀

实现

  在配置文件中添加:server.servlet.context-path: /api(不同SpringBoot版本会有区别,这里是采用2.0)

结果

  定义的两个方法,路径为/test1和/test2

  

  请求路径前得添加前缀/api才能访问到

      

猜你喜欢

转载自www.cnblogs.com/maguanyue/p/11856362.html