Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring SimpleUrlHandlerMapping:图案不';不匹配URL_Spring_Url Mapping - Fatal编程技术网

Spring SimpleUrlHandlerMapping:图案不';不匹配URL

Spring SimpleUrlHandlerMapping:图案不';不匹配URL,spring,url-mapping,Spring,Url Mapping,我有以下映射: <bean id="controllerMappingProperties" class="java.util.Properties"> <constructor-arg> <props> <prop key="/service/q-*-fltr-brand-_-*-find-html.html">redirectController</prop>

我有以下映射:

<bean id="controllerMappingProperties" class="java.util.Properties">
    <constructor-arg>
        <props>
            <prop key="/service/q-*-fltr-brand-_-*-find-html.html">redirectController</prop>
            <prop key="/service/q">queryController</prop>
            <prop key="/service/q-*.html">queryController</prop>
        </props>
    </constructor-arg>
</bean>
映射工作正常

在模式中使用两个单星可以与其他映射一起工作,因此这不会是问题。我做错了什么

谢谢你的帮助

我几天前遇到过。问题在于用于对匹配路径集合进行排序的
AntPatternComparator

在您的情况下,将路径从
/service/q-*.html
更改为
/service/q-**.html
。这没有多大意义,但它应该会起作用


如果查看用于获取当前请求的匹配条件的方法
RequestMappingInfo.getMatchingCondition
,您将看到以下注释,其中指出最佳匹配模式将位于列表的第一位

Spring 4源

/**
*检查此请求映射信息中的所有条件是否与提供的请求匹配并返回
*具有针对当前请求定制的条件的潜在新请求映射信息。
*例如,返回的实例可能包含与
*当前请求,按顶部的最佳匹配模式排序。
*@如果所有条件匹配,则返回一个新实例;或者{@code null}否则
*/
@凌驾
公共请求MappingInfo getMatchingCondition(HttpServletRequest请求){
// ...
}
AntPatternComparator
基本上取决于
*
{
存在于模式中。如果它们的数字相同,则将比较模式长度。当使用
AntPatternComparator
对模式集合进行排序时,您的
/service/q-foo-fltr-brand--*-find html.html
路径将大于基于长度的
/service/q-*.html
。因此
/service/q-*.html
将在顶部结束


添加额外的通配符使
/service/q-**.html
成为最大的通配符,因为它的通配符计数更高。

它可以工作。但我也想知道为什么。我希望有人能回答这个问题。
<prop key="/service/q-*-fltr-brand-_-bar-find-html.html">redirectController</prop>`
or
<prop key="/service/q-foo-fltr-brand-_-*-find-html.html">redirectController</prop>
/**
 * Checks if all conditions in this request mapping info match the provided request and returns
 * a potentially new request mapping info with conditions tailored to the current request.
 * <p>For example the returned instance may contain the subset of URL patterns that match to
 * the current request, sorted with best matching patterns on top.
 * @return a new instance in case all conditions match; or {@code null} otherwise
 */
@Override
public RequestMappingInfo getMatchingCondition(HttpServletRequest request) {
        // ...
}