ActionForm中Field的名称和jsp里的一致吗?

解决方案 »

  1.   

    就是你的jsp里面写控件的名字,没有跟你的ActionForm中的set方法对应起来
      

  2.   

    命名规则是像这样 actionForm。开头不能大写。
      

  3.   

    Action:public class K1320Form extends ActionForm { private String actionFlag = null;
    private String focusName = null;
    private String focusIndex = null;
    private String cptyType = null;
    private String sWIFTType = null;
    private String tag20 = null;
    private String referenceNo = null;
    private String versionID = null;
    private String tag79 = null;
    private String cptyType_1 = null;
    private String cptyType_2 = null;
    private String cptyType_3 = null;
    private String oKCancelFlag = null;
    private String cptyID = null;
    private String cptyID_title = null;
      

  4.   

    Action:package topibs.struts.swift;import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;import topibs.helper.*;
    import java.util.*;
    import topibs.utility.*;
    /**
     * @version  1.0
     * @author
     */
    public class K1320Action extends Action { /**
    * Constructor
    */
    public K1320Action() { super(); }
    public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception { ActionErrors errors = new ActionErrors();
    ActionForward forward = new ActionForward();
    // return value
    K1320Form k1320Form = (K1320Form) form; try 
    { // do something here
    SWIFTBean obj_SWIFTBean = new SWIFTBean();
    Vector vtr_CptyList= new Vector();
    String str_ActionFlag =k1320Form.getActionFlag();

    System.out.println("str_ActionFlag:Action::"+k1320Form.getTag20());
    System.out.println("str_ActionFlag:Action::"+k1320Form.getSWIFTType());
    System.out.println("str_ActionFlag:Action::"+k1320Form.getCptyID());
    System.out.println("str_ActionFlag:Action::"+k1320Form.getCptyType_2());
    System.out.println("str_ActionFlag:Action::"+k1320Form.getReferenceNo());
    System.out.println("str_ActionFlag:Action::"+k1320Form.getTag79());
    System.out.println("str_ActionFlag:Action::"+str_ActionFlag);

    if(str_ActionFlag.equals("GetCptyList"))
    {

            String str_temp1 = request.getParameter("cptyType_1");
            String str_temp2 = request.getParameter("cptyType_2");
            String str_temp3 = request.getParameter("cptyType_3");
            Vector vtr_CptyType = new Vector();
            vtr_CptyType.add(str_temp1);
            vtr_CptyType.add(str_temp2);
            vtr_CptyType.add(str_temp3);
            System.out.println("vtr_CptyTypevtr_CptyType::"+vtr_CptyType);
            
             obj_SWIFTBean.getCptyList(vtr_CptyType);
             vtr_CptyList=obj_SWIFTBean.getCptyList();
             System.out.println("vtr_CptyList::"+vtr_CptyList);
             request.setAttribute("CptyList",vtr_CptyList);
            
                System.out.println("over:over::");
    }
    else if(str_ActionFlag.equals("NEW"))
            {
           vtr_CptyList.add(new TopLinkedHashMap());
             System.out.println("vtr_CptyList::"+vtr_CptyList);
             request.setAttribute("CptyList",vtr_CptyList);
            } 
            
            
        
    } catch (Exception e) { // Report the error using the appropriate name and ID.
    e.printStackTrace();
    errors.add("name", new ActionError("id")); } // If a message is required, save the specified key(s)
    // into the request for use by the <struts:errors> tag. if (!errors.empty()) {
    saveErrors(request, errors);
    }
    // Write logic determining how the user should be forwarded.
    System.out.println("errors::"+errors);
    forward = mapping.findForward("K1320");
    System.out.println("request::"+request);
    // Finish with
    return (forward); }
    }
      

  5.   

    getXxxxxx()和setXxxxx只能有一个大写。比如:getCptyID(),有三个大写。只有:getTag20()可以取到值。
      

  6.   

    这个问题我也碰到过,当时是在TOMCAT下调试的,因为这个东西不是很稳定,不一定是问题
      

  7.   

    你的Form里面连get和set方法都没有怎么取值呀?