通过spring boot yaml配置文件修改上下文跟
yaml
可通过如下方式
server:
## 应用服务 WEB 访问端口
port: 8081
## 应用服务 WEB 上下文跟
servlet:
context-path: /potato-web-market
.application
可通过如下方式:
server.servlet.context-path= /potato-web-market
比如定义的控制器测试为:
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class MallController {
@ResponseBody()
@RequestMapping("/hello")
public String test(){
return "hello";
}
}
通过locahost:8081/potato-web-market请求结果为: