用Struts1做的一个项目。Struts-config.xml配置是:(有的东西省略了)
<form-bean name="newform" type="forms.tuangou.TuanGouForm" />
        <action path="/new" name="newform" input="newTuangou.jsp"
type="actions.tuangou.ActionNewCreate">
<forward name="success" path="houtai/index.jsp" />
<forward name="fail" path="fail.jsp" />
</action>
前台JSP页面:
<form id="login-user-form" method="post" class="validator"
action="../new.do" enctype="multipart/form-data">
<div class="wholetip clear">
<h3>
1、基本信息
</h3>
</div>
<div class="field">
<label>
城市及分类
</label>....Action中:
public ActionForward execute(ActionForm form, ActionMapping mapping,
HttpServletRequest request, HttpServletResponse response) {
ActionForward forward = null;
NewCreateDao dao = new NewCreateImp();
TuanGouForm forms = (TuanGouForm) form;
System.out.println("ActionNewCreat:form:"+form.toString());
System.err.println("ActionNewCreat:forms:city:"+forms.getCity());输出的结果是:
ActionNewCreat:form:forms.tuangou.TuanGouForm@f55759
ActionNewCreat:forms:city:null疑问:
ActionNewCreat:form:forms.tuangou.TuanGouForm@f55759说明ActionForm已经被实例化为我想要的TuanGouForm,但是为什么得不到前台JSP页面中的值?我在TuanGouForm中已经自动生成了set和get方法。