代码之家  ›  专栏  ›  技术社区  ›  Tom Stickel

IBM WebSphere部署Angular 5应用程序并在刷新时获取404

  •  1
  • Tom Stickel  · 技术社区  · 6 年前

    我使用Angular(当前版本5)构建全栈应用程序,通常后端是 Windows Server 它使用 IIS ,因此我知道如何部署web。包含重写模块代码的配置文件。

    问题是该站点是一个SPA,它需要始终指向索引。html,无论URL怎么说。。。

    正如我所说,我习惯windows,但后端是Java IBM Websphere

    有人知道我需要做什么才能有一个正常工作的角度应用程序吗?

    例如,WINDOWS的配置是web。配置如下,但这是带有Java应用程序的Websphere,我假设后端是 Linux/unix

    <configuration>
    <system.webServer>
      <rewrite>
        <rules>
          <rule name="Angular Routes" stopProcessing="true">
            <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/MyApp/" />
          <!--<action type="Rewrite" url="/" />-->
          </rule>
        </rules>
      </rewrite>
    </system.webServer>
    </configuration>
    
    1 回复  |  直到 6 年前
        1
  •  3
  •   lwestby    6 年前

    您需要将以下内容添加到web。xml,它打包在中的WEB\u INF目录中。应用程序的war文件:

    <error-page>
        <error-code>404</error-code>
        <location>/</location>
    </error-page>
    

    它告诉应用程序服务器在发出404错误时在应用程序的上下文根目录下显示资源。