How do I configure Java EE running on GAE to work with Angular UI Router in html5Mode?

元气小坏坏 提交于 2020-01-22 17:46:06

问题


I am attempting to set the UI Router location provider html5Mode to true for my Angular application: locationProvider.html5Mode(true). While this works client side (appropriately redirects) I am running into issues server side. I am running an instance Java Enterprise Edition on Google App Engine.

I have configured my web.xml as outlined for Java EE section in the Angular ui-router FAQ:

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
   <error-page>
        <error-code>404</error-code>
        <location>/</location>
   </error-page>
   <servlet>
        <servlet-name>SystemServiceServlet</servlet-name>
        <servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
        <init-param>
            <param-name>services</param-name>
            <param-value>
                <!-- stuff specific to my GAE app -->
            </param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>SystemServiceServlet</servlet-name>
        <url-pattern>/_ah/spi/*</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>

Sadly even with the above configuration when I browse to client based routes I am still receiving a 404 error from the server. I have tried various values (/index.html, index.html) for the error-page > location element with the same result.

I am probably missing something obvious in my configuration, but am at a loss to what I am doing wrong.

来源:https://stackoverflow.com/questions/41783634/how-do-i-configure-java-ee-running-on-gae-to-work-with-angular-ui-router-in-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!