【问题标题】:put with HttpMethodFilter not working with urlRewrite使用 Http 方法过滤器不使用 url 重写
【发布时间】:2010-01-19 04:55:47
【问题描述】:

我已将 web.xml 放入其中,其中 httpMethodFilter 用于将 post 方法转换为 put 和 delete,但不适用于 urlRewrite

调度员 org.springframework.web.servlet.DispatcherServlet 2 调度员 /应用程序/*

<!-- For converting POST methods to PUT and DELETE methods-->
<filter>
    <filter-name>httpMethodFilter</filter-name>
    <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>httpMethodFilter</filter-name>
    <servlet-name>dispatcher</servlet-name>
</filter-mapping>


<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>
</filter-mapping>

urlrewrite.xml

<urlrewrite default-match-type="wildcard">
    <rule>
        <from>/scripts/**</from>
        <to last="true">/scripts/$1</to>
    </rule>
    <rule>
        <from>/css/**</from>
        <to last="true">/css/$1</to>
    </rule>
    <rule>
        <from>/</from>
        <to last="true">/app/index</to>
    </rule>
    <rule>
        <from>/app/**</from>
        <to last="true">/app/$1</to>
    </rule>
    <rule>
        <from>/**</from>
        <to>/app/$1</to>
    </rule>
    <outbound-rule>
        <from>/app/**</from>
        <to>/$1</to>
    </outbound-rule> </urlrewrite>

控制器代码

   @RequestMapping(method = RequestMethod.PUT, value = "/{articleId}/edit")
    public String update(Article article,ModelMap model) {
//code here 
}

请找出问题

【问题讨论】:

    标签: java spring-mvc


    【解决方案1】:

    你应该添加 url-pattern

     <filter-mapping>
            <filter-name>httpMethodFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    

    【讨论】:

      猜你喜欢
      • 2014-03-25
      • 2010-11-10
      • 2013-03-16
      • 2011-07-25
      • 2012-07-11
      • 1970-01-01
      • 1970-01-01
      • 2012-06-03
      • 2013-05-03
      相关资源
      最近更新 更多