有兩種方式:
- localhost:8080/#/blog 像這樣在端口和實際的訪問路徑前面加個#號,但是這樣未免太醜陋了
@Controller public class ViewController { @RequestMapping({"/blog", "/bikes", "/milages", "/gallery", "/tracks", "/tracks/{id:\\w+}", "/location", "/about", "/tests", "/tests/new", "/tests/**", "/questions", "/answers"}) public String index() { return "forward:/index.html"; } }
像上面這樣,把特定的請求映射到 index.html 上。這樣就可以走Angular2 的處理邏輯而不用走springboot的處理邏輯了。