【问题标题】:Angular11 html in Struts 1.3 project can't find resourcesStruts 1.3项目中的Angular11 html找不到资源
【发布时间】:2021-09-02 01:50:41
【问题描述】:

我想将一个新的 Angular 11 项目集成到一个旧的、遗留的 Struts 1.3 项目中。我将 Angular 放在一个文件夹中,并设置了 package.json,以便将构建文件与其余 Struts 文件一起放入 /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。

知道为什么我无法访问这些文件吗?

【问题讨论】:

    标签: angular struts-1


    【解决方案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 文件中包含脚本和样式引用,以便 web 应用程序可以加载这些资源,因为 tile 定义只导入 HTML。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-14
      • 2022-11-24
      • 2011-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-29
      • 1970-01-01
      相关资源
      最近更新 更多