方法1-struts2-conventionプラグインを使用
struts.xml
<constant name="struts.patternMatcher" value="namedVariable"/>
PersonAction.java
import org.apache.struts2.convention.annotation.Namespace;
...
@Namespace{"/persons/{param1}/{param2}");
public class PersonActionBean exends ActionSupport {
private String param1;
private String param2;
// getter and setter
}
を呼び出す場合はpersons/jack/black
、paramsをに設定する必要がありますparam1 = jack
。param2 = black
方法2-struts2-conventionプラグインなし
PersonAction.java
public class PersonActionBean exends ActionSupport {
private String param1;
private String param2;
// getter and setter
}
person.xml
<package name="person" namespace="/person" extends="website">
<action name="*/*" method="getPerson" class="PersonActionBean">
<param name="param1">{1}</param>
<param name="param2">{2}</param>
<result>/person/view.jsp</result>
</action>
</package>
struts.xml
<package name="website" namespace="/" extends="struts-default, json-default">
...
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
...
</package>
参考文献
AdvancedWildcardをチェックしてください