SAP Spartacus里的路由机制共同有4种:
When Spartacus is launched, the route is handled by the router logic. There are 4 different types of routing that will be evaluated:
(1) the route should be handled by a custom router path; the customer has added hard-coded routes, and we should prioritise those.
(2) the route is either a PLP or PDP
(3) the route is a CMS content page
(4) the route is unknown (404 not found)
When an incorrect URL is passed to Spartacus, it will likely end up in the 3rd type. Spartacus will use the CMS api to fetch the content page for the given URL.
如果一个并不存在的url传递给Spartacus,会被当成content page处理,Spartacus会使用CMS API去读取该url对应的content page.
If the CMS cannot find a matching content page, it will respond with a 404 error. Spartacus will handle this 404 error, and redirect the user (under the hood) to the not found CMS page.
如果CMS返回404错误,Spartacus会显示CMS里model的not found CMS页面。
结果:显示not found页面

步骤如下:
navigation start:
app.module.ts:115 Jerry: NavigationStart(id: 1, url: ‘powertools-spa/en/USD/jerry’)
第二步:
Jerry: RoutesRecognized(id: 1, url: ‘powertools-spa/en/USD/jerry’, urlAfterRedirects: ‘powertools-spa/en/USD/jerry’, state: Route(url:’’, path:’’) { Route(url:‘jerry’, path:’**’) } )
第三步:
Jerry: GuardsCheckStart(id: 1, url: ‘powertools-spa/en/USD/jerry’, urlAfterRedirects: ‘powertools-spa/en/USD/jerry’, state: Route(url:’’, path:’’) { Route(url:‘jerry’, path:’**’) } )
第四步:
Jerry: ChildActivationStart(path: ‘’)
app.module.ts:115 Jerry: ActivationStart(path: ‘**’)
404错误: