> 文章列表 > springboot的rest服务配置服务的根路径

springboot的rest服务配置服务的根路径

springboot的rest服务配置服务的根路径

如果不配置默认为空,如下是application.yml文件只配置了端口号

server:port: 6868

那么访问时直接访问服务即可

 如果配置了rest服务

@RestController
@RequestMapping("/netLicense")
public class NetLicenseController {@RequestMapping("/getLicense")public AjaxResult getLicense(){List<String> license = LicenseMain.getLicense();return AjaxResult.success(license);}
}

浏览器 访问的时候如下

http://localhost:6868/netLicense/getLicenseicon-default.png?t=N2N8http://localhost:6868/netLicense/getLicense

效果

 

 如果配置了上下文地址,如下

server:port: 6868servlet:context-path: /mywebname

启动时

 浏览器访问时

http://localhost:6868/mywebname/netLicense/getLicenseicon-default.png?t=N2N8http://localhost:6868/mywebname/netLicense/getLicense