struts1.2 LazyValidatorForm的用法,代替多余的烦人的actionform

struts 如何去掉那多余的 actionform
而使用LazyValidatorForm

struts-config.xml

























JSP

<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>


JSP for lazyForm form



用户名

年龄

密码

文件

选择1
选择2

非用户信息









Action
package test;

import javax.servlet.http.*;

import org.apache.commons.beanutils.*;
import org.apache.struts.action.*;
import org.apache.struts.actions.*;
import org.apache.struts.upload.*;

public class UserAction extends DispatchAction {

/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward addUser(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaBean lazyForm = (DynaBean) form;
System.out.println(lazyForm.get("c1"));
System.out.println(((FormFile) lazyForm.get("testfile")).getFileSize());
System.out.println(lazyForm.get("user"));
return mapping.findForward("addUser");
}

}

你可能感兴趣的:(Struts,Apache,Bean,JSP,XML)