Angularjs 无法使用某些URL获取角度HTML5模式和URL重写筛选器

Angularjs 无法使用某些URL获取角度HTML5模式和URL重写筛选器,angularjs,angular-ui-router,tuckey-urlrewrite-filter,Angularjs,Angular Ui Router,Tuckey Urlrewrite Filter,我正在使用一个带有Java/Jersey REST API的AngularJS 1.3WebApp。我终于使用了HTML5模式,所以像localhost:8080/#/page这样简单的东西现在就是localhost:8080/page。但是,我似乎无法让像localhost:8080/mypage/category/subcategory/item这样更复杂的东西正常工作。当在单个浏览器选项卡中时,此url将以HTML5模式加载,但如果在新选项卡中打开链接,则会得到404 以下是我的pom和w

我正在使用一个带有Java/Jersey REST API的AngularJS 1.3WebApp。我终于使用了HTML5模式,所以像localhost:8080/#/page这样简单的东西现在就是localhost:8080/page。但是,我似乎无法让像localhost:8080/mypage/category/subcategory/item这样更复杂的东西正常工作。当在单个浏览器选项卡中时,此url将以HTML5模式加载,但如果在新选项卡中打开链接,则会得到404

以下是我的pom和web.xml文件:

pom.xml

<filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
    <init-param>
        <param-name>confPath</param-name>
        <param-value>/WEB-INF/urlrewrite.xml</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

URL重写过滤器
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
confPath
/WEB-INF/urlrewrite.xml
URL重写过滤器
/*
要求
向前地
web.xml:

<urlrewrite>
    <rule match-type="wildcard">
        <from>*/page</from>
        <to>index.html</to>
    </rule>

    // what should this rule look like in order to recognize a url like:
    // localhost:8080/mypage/category/subcategory/item
    <rule match-type="wildcard">
        <from>?</from>
        <to>index.html</to>
    </rule>
</urlrewrite>

*/页面
index.html
//为了识别url,此规则应该是什么样子的:
//本地主机:8080/mypage/category/subcategory/item
?
index.html
我通读了URLEwriteFilter文档,并尝试使用通配符匹配和正则表达式语法的不同变体,但最终总是得到404

我还要补充一点,我使用的是angular ui路由器版本0.2.13,我的页面/状态url类似于/mypage/:category/:subcategory/:item


因此,我的问题是如何匹配此模式,以便重定向到index.html在HTML5模式下正常工作,还是应该以不同的方式配置路由,以便更好地使用URLRewiteFilter

以下是我最终使用的

<urlrewrite>
<rule match-type="regex" enabled="true">
    <condition type="request-filename" operator="notfile" />
    <condition type="request-filename" operator="notdir" />
    <condition type="request-uri" operator="notequal">(\.html|\.js)</condition>
    <from>^/html/(.*rootpage1.*|.*rootpage2.*)$</from>
    <to last="true">/html/index.html</to>
</rule>

(\.html\.js)
^/html/(.*rootpage1..*rootpage2.*)$
/html/index.html

因为我的应用程序正在使用

我还必须将index.html上的引用从relative改为
href=“/myapp/html/otherpage.html”
,因为例如,在/myapp/html/rootpage1/page1/something上使用相对引用时,重写会将url传递到index.html,它位于rootpage1/scope上,而不是html/scope上