sttuts2.配置请求路径二种方式

一:只有类配置
引用

<action name="noextends" class="com.struts.noextendsAction">
            <result name="path">/Hello.jsp</result>
  </action>

(1)默认执行类中的execute方法:http://localhost:8080/项目名/extends
(2)可以动态访问:http://localhost:8080/项目名/extends!add,但是struts默认不启用这种方式,配置如下:
引用

<constant name="struts.enable.DynamicMethodInvocation" value="true" />


二:配置方法名和类名,用通配符配置
引用

<action name="*_*" class="com.struts.{1}Action" method="{2}">
            <result name="{2}">/{2}.jsp</result>
</action>

(1)可以动态访问:http://localhost:8080/项目名/extends_add

注意:如同时配置以上两种方式,访问路径时,与精确度决定先访问哪个配置

猜你喜欢

转载自javafu.iteye.com/blog/1981139