I tried to include dot . in a dynamic URL pattern in Struts 2 but it is not working
My Struts 2 configuration for dynamic URL is as follows
<struts>
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
<constant name="struts.patternMatcher" value="regex" />
<package name="api" extends="struts-default" namespace="/">
<action name="api/v1/{sid}/function/{id}/version/{ver}" class="com.test.Main" method="test">
<param name="sid">{sid}</param>
<param name="id">{id}</param>
<param name="ver">{ver}</param>
</action>
</package>
if I give trigger a URL without any dot in URL then it is working
/api/v1/test/function/1234/version/1
but if I use it with dot as follows then it is giving 404
/api/v1/test/function/1234/version/1.1
Why is it not working? How to make it work?
Dots
.in URL means a file extension delimiter. While you are using data in the URL it should be encoded. The encoded value for the dot is%2E.It's not Struts2 problem to use data with the parameters in the action name, but some characters if not properly encoded has special meaning. For detaild explanation of URL specification see RFC 1738.