gpt4 book ai didi

java - 使用 Http 方法过滤器放置不适用于 url 重写

转载 作者:行者123 更新时间:2023-12-01 05:58:20 27 4
gpt4 key购买 nike

我已经放入了 web.xml,其中 httpMethodFilter 用于将 post 方法转换为放置和删除,但不能与 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>

Controller 代码

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

请确定问题

最佳答案

您应该添加 url-pattern

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

关于java - 使用 Http 方法过滤器放置不适用于 url 重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2091172/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com