1.Struts2中默认动态方法调用是默认关闭的,下面是开启此功能。是放在 struts.xml
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
2.Action的配置如此
<action name="*_*" class="com.xjtu.st.{1}actions" method="{2}">
<result >
/demo/{1}_{2}.jsp
</result>
</action>
{1}代表第一个星号,
{2}代表第一个星号
根据在网上输入的网址自动检查java类文件,自动调用其中的方法,自动转到jsp页面
比如在我的电脑里输入http://localhost:8080/strut2001/path/Student_add
就会去找com.xjtu.st.Studentactions类,调用其中的add方法,再去跳转到/demo/Student_add.jsp页面