【发布时间】:2017-02-27 20:28:47
【问题描述】:
我正在设置一个Play Framework 2.5 服务器以使用Angular 的 SPA(单页应用程序)方法,并希望使用删除 HashTags(#example)的PathLocationStrategy
当我第一次访问服务器时页面加载正常,但如果我刷新或在添加书签后返回,会给出404
在 Angular documentation for Angular Router 中声明需要服务器端配置
有很多关于如何使用nginx 或apache 执行此操作的信息,但是在没有代理的情况下如何在 Play 中执行此操作?
这是我的角度路由器配置:
const routes: Routes = [
{
path: 'main',
component: JobsComponent
},
{
path: 'job-details',
component: JobDetailsComponent
},
{
path: 'job-submit',
component: JobSubmitComponent
},
{
path: '',
redirectTo: '/main',
pathMatch: 'full'
},
{
path: '**',
redirectTo: '/main',
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
providers: []
})
export class AppRoutingModule { }
播放routes.conf
GET / controllers.Assets.at(path="/public", file="index.html")
【问题讨论】:
标签: playframework angular2-routing playframework-2.5