1

I have the following struts2.xml

<struts>

    <constant name="struts.enable.SlashesInActionNames" value="true"/>
    <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
    <constant name="struts.patternMatcher" value="regex" />
    <constant name="struts.devMode" value="true" />

    <package name="ro.fiveplus.cms" namespace="/" extends="struts-default">

        <action name="/{categoryName}/aaaa" method="test" class="test.Test">
             <interceptor-ref name="debugging"/>
             <interceptor-ref name="staticParams">
              </interceptor-ref>
            <result name="success">/index.jsp</result>
        </action>

    </package>

</struts>

and

public class Test extends ActionSupport{

    Map<String, String> params;     
    private String categoryName;

    private static final long serialVersionUID = -5666734745185765139L;

    public String test(){               
        System.out.println("categoryName: "+categoryName);
        return SUCCESS;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }
}

with the libs

antlr-2.7.7.jar
commons-beanutils-1.9.2.jar
commons-collections-3.2.jar
commons-digester-2.0.jar
commons-fileupload-1.2.1.jar
commons-io-2.4.jar
commons-lang-2.6.jar
commons-lang3-3.3.2.jar
commons-logging-1.2.jar
compiler-0.8.4.jar
dom4j-1.6.1.jar
freemarker-2.3.20.jar
guava-18.0.jar
javassist-3.18.2-GA.jar
jaxen-1.1.1.jar
jboss-transaction-api_1.2_spec-1.0.0.Final.jar
jcl-over-slf4j-1.7.7.jar
log4j-1.2.15.jar
mvel2-2.0.11.jar
ognl-3.0.6.jar
slf4j-api-1.7.7.jar
spring-core-3.2.0.RELEASE.jar
spring-web-3.2.0.RELEASE.jar
struts2-core-2.3.20.jar
velocity-1.7.jar
velocity-tools-2.0.jar
xwork-core-2.3.20.jar

If I access

http://localhost:8080/test2/category1/aaaa.action

in console it prints correctly categoryName: category1

but if I access

http://localhost:8080/test2/category1,category2/aaaa.action

in console it prints categoryName: category1category2 instead of categoryName: category1,category2

It seems that it strips some characters like comma and also blank spaces.

It works with Struts version 2.2.31.

Is any work around to solve this ?

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Adrian G.
  • 31
  • 6
  • Have you tried using the `fieldName:regex` syntax as described in [Advanced Wildcards](https://struts.apache.org/docs/wildcard-mappings.html#WildcardMappings-AdvancedWildcards)? – Dave Newton Mar 09 '15 at 17:34
  • 1
    In console before it prints name of the category it also shows `Action [category1,category2/aaaa] does not match allowed action names pattern [[a-zA-Z0-9._!/\-]*], cleaning it up!`. That means that `,` isn't allowed action name. – Aleksandr M Mar 09 '15 at 18:32
  • 1
    @AleksandrM You should make your comment as an answer. – Roman C Mar 09 '15 at 21:11

1 Answers1

1

SOLVED ! I added

<constant name="struts.allowed.action.names" value="[,a-zA-Z0-9._!/\-]*" />

in the struts.xml and everything is ok

Default was "[a-zA-Z0-9._!/\-]*"

Thanks @AleksandrM for the hint !

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Adrian G.
  • 31
  • 6