tags:

views:

26

answers:

1

Is there an easy way to make Struts 2 action names case insensitive? Currently I have the following action defined:

<action name="printTest" class="MyClass" >
  <result name="error">/WEB-INF/jsp/error.jsp</result>
  <result name="input">/WEB-INF/jsp/test.jsp</result>
  <result name="success">/WEB-INF/jsp/test.jsp</result>
</action>

If the user types URL "/app/printtest.do" instead of "/app/printtest.do" this action is not executed.

Other then mod_rewrite on the httpd level or something like that, the only option that I know about right now is simply adding the same exact action and changing the name to "printtest". Ideally it would be a simple config change to struts.xml

A: 

No configurable option, AFAIK, for case insensitive mapping.

So, I believe you have answered the question yourself: either Apache's mod_rewrite, or write the extra mappings in the config.

You could also write your own ActionMapper, extending DefaultActionMapper (method parseNameAndNamespace() ), but I suspect it would be overkill... :-)

leonbloy