dispatchAction减少Action的数量,但是这也为多个ActionForm共享一个DispatchAction带来了困难,一种最直接的方法就是将多个要用dispatchAction的actionform中的元素全部写在同一个ActionForm中,但是这使得这个ActionForm变得很臃肿,维护起来有难度,所以我们可以将这些属性分一下层,把一些属性放在一个类里面,让后把这个类放在ActionForm中
例如:
String cellphone;
String mobile;
String z;
getter and setter……
优化后
Phone p;
Address a;
getter and setter......
class Phone
{
String cellphone;
String moblie;
getter and setter.......
}
html中的表单输入也要做相应变化
<input name="p.cellphone" type="text" />