代码之家  ›  专栏  ›  技术社区  ›  developerwjk

Url重写是重定向而不是在后端重写

  •  0
  • developerwjk  · 技术社区  · 12 年前

    我以为tukey urlrewrite过滤器会在后端重写URL。就像我在地址栏中键入 http://localhost:8080/TEST/some/yo 我希望该地址保留在地址栏中,但在Tomcat的后端处理它,就像我键入了 http://localhost:8080/TEST/jspinwebinftest/?param=yo 但相反,它将重定向到 http://localhost:8080/TEST/jspinwebinftest/?param=yo 并在地址栏中显示。

    我如何让它只在后端重写URL?这是我的urlrewrite.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE urlrewrite
        PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
        "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
    <urlrewrite>
        <rule>
           <from>^/some/(.*)$</from>
           <to type="redirect">/TEST/jspinwebinftest/?param=$1</to>
        </rule>
    </urlrewrite>
    
    1 回复  |  直到 12 年前
        1
  •  1
  •   developerwjk    12 年前

    我找到了答案。其实很简单。我需要删除 type="redirect" 这是塔克网站上的XML示例。我发现在重定向时,你必须在 to 标记,但如果不重定向,则不应:

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE urlrewrite
        PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
        "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
    <urlrewrite>
        <rule>
           <from>^/some/(.*)$</from>
           <to>/jspinwebinftest/?param=$1</to>
        </rule>
    </urlrewrite>