【问题标题】:How to configure maven urlrewrite如何配置maven urlrewrite
【发布时间】:2015-04-08 13:15:23
【问题描述】:

因此,我们目前支持两个网络应用,并希望在不久的将来停止这样做。因此,所有针对我们想要重定向到静态页面的旧 maven 项目的 url。

为此,我有:

1- 添加以下依赖项:

<dependency>
  <groupId>org.tuckey</groupId>
  <artifactId>urlrewritefilter</artifactId>
  <version>4.0.3</version>
</dependency>

2- 在我的 web.xml 文件中添加以下内容(在 jstl 设置之后和 servlet 设置之前)

<filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

然后添加一个带有以下规则的urlrewrite.xml文件只是为了测试:

<urlrewrite>
    <rule>
        <from>http://localhost/start/of/url/ (the actual start of the url)</from>
        <to type="redirect">http://www.google.com/</to>
    </rule>
</urlrewrite>

我对这个概念/配置完全陌生,因为我正在处理一个 spring 项目,但必须修改这个不在 spring 中的 maven web 应用程序。 所以重定向没有生效,根本不影响流程,有什么想法吗?

更新:我将 from 标签更改为 /* 这行得通,但是它将我重定向到的页面是http://www.google.com/http://www.google.com/http://www.google.com/http://www.google.com/(彼此多次),有什么想法吗?

【问题讨论】:

  • 你能把你的 web XML 放进去吗,在这之前还有其他过滤器吗?
  • 是的,还有其他过滤器,但都在它之后,它们是来自公司框架@sgpalit 的过滤器

标签: java maven web-applications deployment tuckey-urlrewrite-filter


【解决方案1】:
<urlrewrite>
<rule>
    <from>^(.*)</from>
    <to type="redirect">http://www.google.com/</to>
</rule>
</urlrewrite>

试试这个,它应该可以工作...测试...

【讨论】:

  • 好的,谢谢!打开我的 URL 有问题。再次感谢您!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-07-11
  • 2014-09-08
  • 2012-09-12
  • 1970-01-01
  • 1970-01-01
  • 2013-03-04
  • 2013-05-05
相关资源
最近更新 更多