分析下面的代码:
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
// Extract attributes and parameters we will need
Locale locale = getLocale(request);
MessageResources messages = getResources(request);
HttpSession session = request.getSession();
UserEditForm m_UserEditForm = (UserEditForm) form;actionform通过execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
转过来。
而Action的execute()又是在ActionServlet中处理的,也就是说通过ActionServlet转过来了。
ActionServlet里又通过用户提交的表单取得数据的。
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
// Extract attributes and parameters we will need
Locale locale = getLocale(request);
MessageResources messages = getResources(request);
HttpSession session = request.getSession();
UserEditForm m_UserEditForm = (UserEditForm) form;actionform通过execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
转过来。
而Action的execute()又是在ActionServlet中处理的,也就是说通过ActionServlet转过来了。
ActionServlet里又通过用户提交的表单取得数据的。
public class LoginAction extends Action {
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
/**@todo: complete the business logic here, this is just a skeleton.*/
LoginActionForm loginActionForm = (LoginActionForm) actionForm;
//这里直接调用了name属性的get方法,获得了name属性的值,可是他是在什么时候
执行的setName方法将值赋予name属性的呢??
String name=loginActionForm.getName();
if(name.equals("user")){
return actionMapping.findForward("y");
}
else{
return actionMapping.findForward("n");
}
}
}
这里直接调用了name属性的get方法,获得了name属性的值,可是他是在什么时候
执行的setName方法将值赋予name属性的呢??
是框架自动完成的,可以看看源代码