struts 的Action继承Action与DispatchAction

 
  在做SSH项目中,遇到一个很恼火的问题,在Acion中所有的方法都写了,并且配置文件,以及页面forward信息都写的很清楚,就是在执行的过程中发现页面跳转不了,郁闷之极。通过一段时间的测试,发现原来我的Action继承的是org.apache.struts.action.Action方法,查了API才发现这个方法只会执行execute方法,而DispatchAction会根据parameter(struts配置文件中Action的parameters属性)的值执行特定的方法,注意parameter的值不要设置为execute,也不要覆盖DispatchAction中的execute(),因为DispatchAction继承于Action,它的execute会首先执行,在execute()方法中取出parameter的值,通过java反射调用指定的方法。附上两个的API:http://struts.apache.org/1.x/struts-extras/apidocs/org/apache/struts/actions/DispatchAction.html     http://struts.apache.org/1.x/apidocs/org/apache/struts/action/Action.html

你可能感兴趣的:(apache,html,struts,ssh)