首页 > 解决方案 > Struts 1.3项目中的Angular11 html找不到资源

问题描述

我想将一个新的 Angular 11 项目集成到一个旧的、遗留的 Struts 1.3 项目中。我将 Angular 放在一个文件夹中,并进行了设置,以便将构建文件与其余 Struts 文件一起package.json放入目录中:/webapp

+--src  
| +-- java  
| +-- ui (Angular files)  
| +-- webapp (Struts)   
| | +-- angular build files  
| | +--web-inf (Struts public files)

我使用 JSP 页面上的操作链接链接到我的 Angular 静态 html:

<html:link action="ConfigurationDataSetup.do">

struts-config.xml有一个匹配的动作:

<action
    path="/ConfigurationDataSetup"
    type="org.apache.struts.actions.ForwardAction"
    name="ConfigurationDataSetup"
    parameter="/angular/configurationDataSetup.html">
</action>

当我在本地 WebLogic 服务器上为项目提供服务时,我收到 404 错误,表明项目找不到我的静态角度资源的其余部分。我认为是因为出于某种原因,它正在项目的根目录中寻找它们:

GET http://localhost:7001/styles.css net::ERR_ABORTED 404 (Not Found)
GET http://localhost:7001/runtime.js net::ERR_ABORTED 404 (Not Found)
GET http://localhost:7001/main.js net::ERR_ABORTED 404 (Not Found)
GET http://localhost:7001/polyfills.js net::ERR_ABORTED 404 (Not Found)
GET http://localhost:7001/vendor.js net::ERR_ABORTED 404 (Not Found)

我通过localhost:7001/ScoreReportsWorkbench.
这是为我的登录页面提供服务的 URL。

任何想法为什么我无法访问这些文件?

标签: angularstruts-1

解决方案


我的问题是我的tiles-defs.xml 中没有定义。我创建了一个定义:

<definition name="configurationDataSetup.layout" extends="base.layout">
        <put name="pageName"  value="ConfigurationDataSetup" />
        <put name="body"   value="/angular/configurationDataSetup.html" />
</definition>

这在我的struts-config.xml:

<action forward="configurationDataSetup.layout" path="/ConfigurationDataSetup" />

我还必须在我的base.layout文件中包含脚本和样式引用,以便 webapp 可以加载这些资源,因为 tile 定义只导入 HTML。


推荐阅读