用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方法。
<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方法。
解决方案 »
- JAVA开发,每次都是百万的数据量,用什么ORM比较好?
- 有谁懂bfw框架发送socket报文的大神显灵吧
- jdom
- 在NetBeans中运行正常,但是生成的jar运行不正常,怎么办,急!
- java包的问题
- web在线即时聊天,如何判断对方是否在线???????
- 在线等...高手来看看...在线给分
- 想知道Jakarta Commons DBCP与Proxool的比较
- jboss3.2.0配置mssql2000 DataSource发生如下错误??????
- 急!!!jndi在windows 2000 server下如何配置,up送分!!!
- ajax传对象值
- Java做的数据管理工具网页版,数据库管理工具
之所以ActionForm得不到数据是因为我在JSP页面的<Form>中是写了enctype="multipart/form-data"这句话,我原本的意思是想用SmartUpload上传文件的,但是写了这句话之后上传的数据都是以二进制的方式传递的,这就造成ActionForm得不到数据。那我该怎么才能上传数据?不用SmartUpload也可以