Is there an equivalent for default-action-ref in Struts2 Conventions Plugin

518 views Asked by At

I want to have an action default but not in XML because I want to use annotations using the Struts2 Conventions Plugin.

So I want to replace

<package abstract="true" namespace="/" name="mypackage" extends="struts-default">

<default-action-ref name="index"/>

</package>

with something in annotations, so I don't have to use a struts.xml file but also redirect to a specific action when an unknown action is specified in the URL.

Is there support for this in the Struts2 Convention Plugin or are there any good workarounds that are annotation based?

2

There are 2 answers

0
Yasser Zamani On BEST ANSWER

Currently there is no support but you can request at here.

I don't think that there is a simple tip or workaround!

0
Marc Tarin On

This answer may come a bit late but still be useful to someone.

As mentioned in Struts documentation, an alternative to default actions is using wildcards:

<action name="*">
  <result>/index.jsp</result>
</action>

Or using an annotation:

@Action(value = "*")
@Result(location = "/index.jsp")
public class HomeAction extends ActionSupport {

}