簡體   English   中英

IBM WebSphere部署Angular 5應用程序並刷新404

[英]IBM WebSphere deploy Angular 5 application and getting 404 on refresh

我使用Angular(當前版本5)構建完整堆棧的應用程序,通常后端是Windows Server ,並且使用IIS ,因此我知道要使用重寫模塊代碼部署web.config文件。

問題是該網站是SPA,無論URL表示什么,它都必須始終指向index.html。

正如我所說,我習慣於Windows,但是后端是Java和IBM Websphere

任何人都知道我需要做些什么才能擁有一個正常工作的Angular應用程序?

例如,WINDOWS的配置是如下所示的web.config,但這是具有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>

您需要將以下內容添加到web.xml中,該文件打包在應用程序.war文件中的WEB_INF目錄中:

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

當發出404錯誤時,它告訴應用服務器在應用的上下文根目錄下顯示資源。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM