Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Code Block
titleA Logon Action
<action name="Logon" class="tutorial.Logon">
  <result type="redirectAction">Menu</result>
  <result name="input">/Logon.jsp</result>


When using Convention Plugin the action mapping can be configured with annotations:


Code Block
titleA Hello Form
<s:form action="Hello">
    <s:textfield label="Please enter your name" name="name"/>

Action Names With Slashes

If your action names have slashes in them (for example, <action name="admin/home" class="tutorial.Admin"/>) you need to specifically allow slashes in your action names via a constant in the struts.xml file by specifying <constant name="struts.enable.SlashesInActionNames" value="true"/>. See JIRA Issue WW-1383 for discussion as there are side effects to setting this property to true.


Action Names with Dots and Dashes

Although action naming is pretty flexible, one should pay attention when using dots (eg. create.user) and/or dashes (eg. my-action). While the dot notation has no known side effects at this time, the dash notation will cause problems with the generated JavaScript for certain tags and themes. Use with caution, and always try to use camelcase action names (eg. createUser) or underscores (eg. my_action).

Allowed action names

DefaultActionMapper is using pre-defined RegEx to check if action name matches allowed names. The default RegEx is defined as follow: [a-zA-Z0-9._!/\-]* - if at some point this doesn't match your action naming schema you can define your own RegEx and override the default using constant named struts.allowed.action.names, e.g.:

Code Block
  <constant name="struts.allowed.action.names" value="[a-z{}]"*/>

NOTE: Please be aware that action names not matching the RegEx will rise an exception.

Action Methods

The default entry method to the handler class is defined by the Action interface.