In Struts2 actions are mapped on methods. The above url you should map as
<package name="example" namespace="/" extends="struts-default">
<action name="product" method="search"> <!-- case sensitive -->
<result>product-search.jsp</result>
</action>
</package>
or via annotations
@Namespace("/")
public class ProductAction extends ActionSupport {
public String execute() {
return SUCCESS;
}
@Action(value="product",
results=@Result(location="/product-list.jsp")
)
public String search() {
return SUCCESS;
}
}
Notice, that the method execute
is not mapped, so it will not execute. If you need that method execute you should create mapping to it. For this purpose you could place annotation on class or on method execute
.
More examples you could find on the page Convention Plugin.