如何从springmvc进入angular4页面

How to enter angular4 pages from spring mvc

我有 angular4 + spring mvc 项目这是我的项目层次结构

我的index.html内容

<!DOCTYPE html><html lang="en"><head>
  <meta charset="utf-8">
  <title>MonitoringFront</title>
  <base href="./">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root></app-root>


    <script type="text/javascript" src="runtime.js"></script><script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="styles.js"></script><script type="text/javascript" src="vendor.js"></script><script type="text/javascript" src="main.js"></script></body></html>

和我的网络配置 class

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = { "ge.mvc"})
public class WebMvcConfig implements WebMvcConfigurer {

    @Bean
       public InternalResourceViewResolver resolver() {
          InternalResourceViewResolver resolver = new InternalResourceViewResolver();
          resolver.setViewClass(JstlView.class);
          resolver.setPrefix("/WEB-INF/monitoringFront");
          return resolver;
       }

}

当我想输入我的页面时,例如登录页面,这是我的默认页面,我 am getting page not fount error 当我试图输入 http://localhost:8080/springMvcApp/ url 时。我做错什么了吗 ?

我的 router urls 来自 angular 4 app.module.ts 文件

const appRoutes:Routes = [
  {
    path: '',
    component: LoginComponent
  },
  {
    path: 'dashboard',
    component: DashboardComponent
  }
]

我认为你的问题等同于这个问题,因为你只想渲染 angular 应用程序,

How to serve .html files with Spring

在我看来,您需要将问题分开,以便在一侧拥有更好的架构,您需要前端使用 angular 5,而在另一侧 spring mvc 来创建 rest服务,您可能还需要 JWT 进行身份验证。