Improve wildcards resolution in action-mappings
-----------------------------------------------
Key: STR-3132
URL: https://issues.apache.org/struts/browse/STR-3132
Project: Struts 1
Issue Type: Improvement
Components: Core
Affects Versions: 1.3.8
Environment: Struts 1.3.8
Reporter: Laurent MORIN
Hello
In my struts-config.xml, i define generic mappings using wildcards to normalize
actions suite.
The is no posibility actualy to define 2 action mappings with the same path
structure but not the same configuration.
My exemple is :
<action path="/*/*/prepare"
name="{1}Form" scope="session"
validate="false"
command="prepare-{2}-{1}" catalog="cctp-{1}"
forward="/{1}/{2}/prepare/rooting.do">
</action>
<action path="/*/*/prepare"
name="{2}Form" scope="session"
validate="false"
command="prepare-{2}-{1}" catalog="cctp-{1}"
forward="/{1}/{2}/prepare/rooting.do">
</action>
Struts always retrieve the second one, even if the mapping is not correct
(wrong form name, wrong command ...)
The only way i found to enable this behavior, is to setup the following
property in action servlet (web.xml)
<init-param>
<param-name>configFactory</param-name>
<param-value>org.apache.struts.config.impl.CustomMatcherModuleConfigFactory</param-value>
</init-param>
And Then redfine , ModuleConfigFactory, ModuleConfigImpl and
ActionConfigMatcher.
Just to redefine the method "match" in ActionConfigMatcher as following:
public ActionConfig match(String path) {
ActionConfig config = null;
if (compiledPaths.size() > 0) {
if (log.isDebugEnabled())
log.debug("Attempting to match '" + path + "' to a wildcard
pattern");
if (path.length() > 0 && path.charAt(0) == '/')
path = path.substring(1);
HashMap vars = new HashMap();
Iterator i = compiledPaths.iterator();
do {
if (!i.hasNext())
break;
Mapping m = (Mapping) i.next();
if (wildcard.match(vars, path, m.getPattern())) {
if (log.isDebugEnabled())
log.debug("Path matches pattern '" +
m.getActionConfig().getPath() + "'");
ActionConfig lTempconfig = convertActionConfig(path,
m.getActionConfig(), vars);
// Test if ActionConfig is correct before returning it
if(StringUtils.isNotBlank(lTempconfig.getName()) &&
lTempconfig.getModuleConfig().findFormBeanConfig(lTempconfig.getName()) ==
null) {
// The form doesn't exists
log.debug("FormBean not defined '" +
lTempconfig.getName() + "' config ignored");
} else {
config =lTempconfig;
}
}
} while (true);
}
return config;
}
In that exemple i just test formBean config but it is important to chek all
actionConfigs such as class, command ...
thanks
LAurent MORIN
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.