Index: stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java =================================================================== --- stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java (revision 1218) +++ stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java (working copy) @@ -52,7 +52,7 @@ * them contain the values (if any) that were extracted from the URI. * *

- * + * * @author Ben Gunter * @since Stripes 1.5 * @see UrlBinding @@ -66,7 +66,7 @@ /** * Get the singleton instance. - * + * * @return an instance of this class */ public static UrlBindingFactory getInstance() { @@ -106,7 +106,7 @@ /** * Get the {@link UrlBinding} prototype associated with the given {@link ActionBean} type. This * method may return null if no binding is associated with the given type. - * + * * @param type a class that implements {@link ActionBean} * @return a binding object if one is defined or null if not */ @@ -126,7 +126,7 @@ * returns the associated binding prototype, if any. No attempt is made to extract parameter * values from the URI. This is intended as a fast means to get static information associated * with a given request URI. - * + * * @param uri a request URI * @return a binding prototype, or null if the URI does not match */ @@ -176,6 +176,9 @@ continue; String string = (String) component; + if (string.endsWith("/")) { + string = string.substring(0, string.length() - 1); + } int at = uri.indexOf(string, idx); if (at >= 0) { idx = at + string.length(); @@ -207,7 +210,7 @@ minComponentCount = componentCount; maxComponentMatch = componentMatch; } - else if (idx == maxIndex && componentCount == minComponentCount) { + else if (idx == maxIndex && componentCount == minComponentCount && componentMatch == maxComponentMatch) { if (conflicts == null) { conflicts = new ArrayList(candidates.size()); conflicts.add(prototype.toString()); @@ -229,7 +232,7 @@ * Examines a servlet request and returns the associated binding prototype, if any. No attempt * is made to extract parameter values from the URI. This is intended as a fast means to get * static information associated with a given request. - * + * * @param request a servlet request * @return a binding prototype, or null if the request URI does not match */ @@ -242,7 +245,7 @@ * returns the associated binding, if any. Parameters will be extracted from the URI, and the * {@link UrlBindingParameter} objects returned by {@link UrlBinding#getParameters()} will * contain the values that are present in the URI. - * + * * @param uri a request URI * @return a binding prototype, or null if the URI does not match */ @@ -324,7 +327,7 @@ * Examines a servlet request and returns the associated binding, if any. Parameters will be * extracted from the request, and the {@link UrlBindingParameter} objects returned by * {@link UrlBinding#getParameters()} will contain the values that are present in the request. - * + * * @param request a servlet request * @return if the request matches a defined binding, then this method should return that * binding. Otherwise, this method should return null. @@ -335,7 +338,7 @@ /** * Get all the {@link ActionBean}s classes that have been found. - * + * * @return an immutable collection of {@link ActionBean} classes */ public HashMap> getPathMap() { @@ -348,7 +351,7 @@ /** * Map an {@link ActionBean} to a URL. - * + * * @param beanType the {@link ActionBean} class * @param binding the URL binding */ @@ -382,7 +385,7 @@ /** * Removes an {@link ActionBean}'s URL binding. - * + * * @param beanType the {@link ActionBean} class */ public synchronized void removeBinding(Class beanType) { @@ -482,7 +485,7 @@ /** * Map a path directly to a binding. If the path matches more than one binding, then a warning * will be logged indicating such a condition, and the path will not be cached for any binding. - * + * * @param path The path to cache * @param binding The binding to which the path should map */ @@ -536,7 +539,7 @@ /** * Add a binding to the set of bindings associated with a prefix. - * + * * @param prefix The prefix to cache * @param binding The binding to map to the prefix */ @@ -567,7 +570,7 @@ * Look for a binding pattern for the given {@link ActionBean} class, specified by the * {@link net.sourceforge.stripes.action.UrlBinding} annotation. If the annotation is found, * create and return a {@link UrlBinding} object for the class. Otherwise, return null. - * + * * @param beanType The {@link ActionBean} type whose binding is to be parsed * @return A {@link UrlBinding} if one is specified, or null if not. * @throws ParseException If the pattern cannot be parsed @@ -585,7 +588,7 @@ /** * Parse the binding pattern and create a {@link UrlBinding} object for the {@link ActionBean} * class. If pattern is null or zero-length, then return null. - * + * * @param beanType The {@link ActionBean} type to be mapped to the pattern. * @param pattern The URL binding pattern to parse. * @return A {@link UrlBinding} or null if the pattern is null or zero-length @@ -684,7 +687,7 @@ * Parses a parameter specification into name and default value and returns a * {@link UrlBindingParameter} with the corresponding name and default value properties set * accordingly. - * + * * @param beanClass the bean class to which the binding applies * @param string the parameter string * @return a parameter object @@ -740,7 +743,7 @@ /** * Returns the URI of the given {@code request} with the context path trimmed from the * beginning. I.e., the request URI relative to the context. - * + * * @param request a servlet request * @return the context-relative request URI * @deprecated Use {@link HttpUtil#getRequestedPath(HttpServletRequest)} instead.