http://localhost:8080/Struts2/test/helloworld!addUI.action
就是在后面加上感叹号和具体需要调用的方法名称,当然了,struts的文档不推荐使用这种方式,所以我们可以在struts.xml文件an里面通过使用静态常量的方式来指定禁止使用这样的动态方法调用
- ### Set this to false if you wish to disable implicit dynamic method invocation
- ### via the URL request. This includes URLs like foo!bar.action, as well as params
- ### like method:bar (but not action:foo).
- ### An alternative to implicit dynamic method invocation is to use wildcard
- ### mappings, such as <action name="*/*" method="{2}" class="actions.{1}">
- struts.enable.DynamicMethodInvocation = true
- <package name="bird" namespace="/test" extends="struts-default">
- <action name="helloworld_*" class="com.bird.action.HelloWorld" method="{1}">
- <result name="success">/WEB-INF/jsp/hello.jsp</result>
- </action>
- </package>
http://localhost:8080/Struts2/test/helloworld_addUI.action
这样使用通配符就可以访问addUI这个方法了。推荐使用这样的方式哦
