struts-config配置文件中,actionmaping里parameter属性干什么用的?
看到在parameter= "method "设了后,页面上提交了参数method=###参数后,就可以直接进入action里###方法,请问这是怎么对应起来的?
初学struts,感觉很神奇!
------解决方案-------------------- <action-mappings>
<action path= "/index " type= "ClassA " name= "mapForm " scope= "request " parameter= "goto ">
<forward name= "jspA " path= "/jspA.jsp " />
<forward name= "jspB " path= "/jspB.jsp " />
</action>
</action-mappings>
public class ClassA extends DispatchAction {
public ActionForward method1(ActionMapping mapping, ActionForm form, ttpServletRequest request, HttpServletResponse response) throws Exception {
return mapping.findForward( "jspA ");
}
public ActionForward method1(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)throws Exception {
return mapping.findForward( "jspB ");
}
}
这里的配置,parameter= "goto ",如果第一个jsp里传来一个参数 "goto "的值为method1,则执行ClassA里面的method1()方法,如果 "goto "的值为method2,则执行method2()方法(参数的值要与方法名相同)。