【发布时间】:2020-07-30 00:18:55
【问题描述】:
我正在用 Angular 7 开发一个应用程序。它的构建是为了更新一个也支持 jsp 页面的遗留应用程序。目前,当我尝试调用 index.jsp 页面时,它会自动重定向到 index.html。我无法调用任何 jsp 页面。它们都在同一个基础href下。我需要将这些 jsp 页面用于某些部分。 应用部署在 websphere 上。
context-url 是门户
<?xml version="1.0" encoding="UTF-8"?>
<web-ext
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_1.xsd" version="1.1">
<reload-interval value="3"/>
<context-root uri="portal" />
<enable-directory-browsing value="false"/>
<enable-file-serving value="true"/>
<enable-reloading value="true"/>
<enable-serving-servlets-by-class-name value="false"/>
</web-ext>
我有 index.jsp 和 index.html。 web.xml 中的欢迎文件列表指向 index.html 在 web.xml 我有多个 url 模式
<web-resource-collection>
<web-resource-name>action</web-resource-name>
<description />
<url-pattern>/manage.do</url-pattern>
<url-pattern>/save.do</url-pattern>
<url-pattern>/legacy.do</url-pattern>
<url-pattern>/acts.do</url-pattern>
</web-resource-collection>
对于我拥有的 index.html 页面
我还在 app-routing-module.ts 中配置了应用路由
const routes: Routes = [
{ path: 'manage.do', redirectTo : '/index.jsp', pathMatch : 'full'},
];
每当我调用网址 https://localhost:9443/portal/ 或 https://localhost:9443/portal/index.html 时, 它转到 index.html
但是当我打电话给https://localhost:9443/portal/index.jsp 或https://localhost:9443/portal/manage.do 时, 它仍然总是重定向到 index.html。
但是我需要它来调用jsp页面并重定向到遗留代码,任何人有任何建议
JSP页面调用manage.do
@RequestMapping(value = "/manage", method = { RequestMethod.GET, RequestMethod.POST })
public ModelAndView portalMainPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
如您所见,它的返回类型为 modelandview,而不是可以通过 angular 重新生成的列表。
它有自己的jsp页面和自己的视图。有没有办法在同一个ear文件中重定向到jsp页面?
【问题讨论】:
-
redirectTo 用于重定向到 Angular 应用程序中的页面。看看这个stackoverflow.com/questions/40150393/…
-
问题是我没有连接到外部链接。 jsp 和 angular 在同一个 EAR 文件中。所以问题是为什么 /portal/index.jsp 或 /portal/manage.do 会自动重定向到 index.html。我正在尝试渲染 jsp 页面,但它一直重定向到角度组件。
标签: java angular spring jsp servlets