You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Laurie Harper <la...@holoweb.net> on 2005/08/02 23:53:05 UTC
Re: Documenting wildcard action mapping behaviour
Excellent, thanks :)
Don Brown wrote:
> I added the patch to Struts core. Thanks again for the patch!
>
> Don
>
> Laurie Harper wrote:
>
>> I got bitten once too many times by unexpected behaviour using wildcard
>> action paths so I dug out my debugger and figured out what was going on.
>> Attached is some extra documentation to save others from confusion.
>>
>> Note, I added a debug log in ActionConfigMatcher (it would have helped me
>> figure out what was going on a lot sooner) but it's probably redundant
>> with
>> the added documentation. Your call, committers ;-)
>>
>> The patch is against CVS HEAD.
>>
>> L.
>>
>> -------------- 8< -------------- 8< -------------- 8< --------------
>>
>> Index: src/share/org/apache/struts/config/ActionConfigMatcher.java
>> ===================================================================
>> RCS file:
>> /home/cvspublic/jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java,v
>>
>> retrieving revision 1.11
>> diff -u -w -B -r1.11 ActionConfigMatcher.java
>> --- src/share/org/apache/struts/config/ActionConfigMatcher.java 1 Apr
>> 2004 17:56:47 -0000 1.11
>> +++ src/share/org/apache/struts/config/ActionConfigMatcher.java 19 Jul
>> 2005 20:59:24 -0000
>> @@ -38,7 +38,9 @@
>> /**
>> * Matches paths against pre-compiled wildcard expressions pulled from
>> * action configs. It uses the wildcard matcher from the Apache
>> - * Cocoon project.
>> + * Cocoon project. Patterns will be matched in the order they exist
>> + * in the Struts config file. The last match wins, so more specific
>> + * patterns should be defined after less specific patterns.
>> *
>> * @since Struts 1.2
>> */
>> @@ -110,6 +112,10 @@
>> for (Iterator i = compiledPaths.iterator(); i.hasNext();) {
>> m = (Mapping) i.next();
>> if (wildcard.match(vars, path, m.getPattern())) {
>> + if (log.isDebugEnabled()) {
>> + log.debug("Path matches pattern '"
>> + + m.getActionConfig().getPath() + "'");
>> + }
>> config = convertActionConfig(
>> path,
>> (ActionConfig) m.getActionConfig(),
>> Index: xdocs/userGuide/building_controller.xml
>> ===================================================================
>> RCS file:
>> /home/cvspublic/jakarta-struts/xdocs/userGuide/building_controller.xml,v
>> retrieving revision 1.2
>> diff -u -w -B -r1.2 building_controller.xml
>> --- xdocs/userGuide/building_controller.xml 27 Apr 2004 22:34:01
>> -0000 1.2
>> +++ xdocs/userGuide/building_controller.xml 19 Jul 2005 20:59:31
>> -0000
>> @@ -1405,6 +1405,15 @@
>> </p>
>>
>> <p>
>> + Mappings are matched against the request in the order they appear in
>> + the Struts configuration file. If more than one pattern matches the
>> + last one wins, so less specific patterns must appear before more
>> + specific ones. However, if the request URL can be matched against
>> + a path without any wildcards in it, no wildcard matching is
>> performed
>> + and order in not important.
>> + </p>
>> +
>> + <p>
>> Wildcard patterns can contain one or more of the following
>> special tokens:
>> </p>
>>
>> -------------- 8< -------------- 8< -------------- 8< --------------
>>
--
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/laurie
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org