1

我已经构建了一个新的 Angular7 应用程序,并且本地 Angular 应用程序运行良好。现在我需要从基于 Java/JSP 构建的现有遗留 Web 应用程序启动我的 Angular 应用程序。在现有的遗留应用程序中,我有一个 URL。单击该 URL 后,应打开 Angular 应用程序。

但是每当我点击 URL 时,似乎路由没有正确地发生在 Angular 应用程序中。

本地 Angular 应用程序在 - http://localhost:4200/alerts;alerttype=renewals;cor=411119上成功运行

到目前为止,我已将 angular dist 文件夹复制到遗留应用程序的 webcontent 文件夹并运行应用程序,如下所示

http://localhost:9086/customer/eWeb/AlertApp/alerts;alerttype=renewals;cor=411119

app.routing.module.ts

    const routes: Routes = [
    { path: 'alerts', component: AlertsComponent },
    { path: 'customer/eWeb/AlertApp/alerts', component: AlertsComponent 
     },
    ];

谁能帮助并告诉如何从遗留应用程序启动角度应用程序?需要配置什么所有路由?

提前致谢。

4

2 回答 2

0

构建 Angular 应用程序后,您将获得一些 js 和 css 文件(取决于您的代码,此处的模式详细信息)

只需在服务器上捆绑和移动这些文件,然后在 JSP 页面上调用主文件 (bundle.js)。

在此之前,不要忘记在 index.html 中设置基本路径

于 2019-06-17T18:54:13.987 回答
0

更新您的服务器端 url 配置(SpringMVC 或 SpringBoot 配置或 Servlet web.xml)以返回您的父 jsp。

http://localhost:9086/customer/eWeb/AlertApp --> app.jsp

在 app.jsp 中,只需包含 css + 捆绑的 js 文件(类似于您的 angular index.html)

<body>
 <div app> </div>
 <script type="text/javascript" src="runtime.js"></script><script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="scripts.js"></script><script type="text/javascript" src="main.js"></script>
</body>
于 2019-06-18T05:39:08.377 回答