解决方案 »

  1.   

    <s:form name="form1" action="product!save.action" method="post"
    onSubmit="return fun_check_form()" enctype="multipart/form-data">
    <table cellspacing="1" cellpadding="0" width="100%" class="tableborder"
    id="table3">
    <tr>
    <td colspan="12" class="header">添加商品信息</td>
    </tr>
    <tr>

    <td class="altbg2" colspan="12"><s:textfield label="商品编号(系列)"
    name="serialnumber" size="34"></s:textfield></td>
    </tr>
    <tr>

    <td class="altbg2" colspan="12"><s:textfield name="pname" label="商品名称:"
    size="34"></s:textfield></td>
    </tr>
    <tr>

    <td class="altbg2" colspan="12"><s:textfield name="brand" label="商品商标:"
    size="34"></s:textfield></td>
    </tr>
    <tr>

    <td class="altbg2" colspan="12"><s:textfield name="price" label="商品价格:"
    size="34" onkeypress="checkIsFloat();" ></s:textfield></td>
    </tr>
    <tr>

    <td class="altbg2" colspan="12"><s:file name="img" label="商品图片:"
    size="34"></s:file></td>
    </tr>
    <tr>

    <td class="altbg2" colspan="12"><s:textarea rows="5" cols="60" label="商品介绍:"
    name="descripte"></s:textarea></td>
    </tr>
    <tr>
    <td class="altbg1"></td>
    <td class="altbg2" colspan="12"><s:submit value="提交"
    name="B1" /> &nbsp; <s:reset value="重置" name="B2" /></td>
    </tr></table>
    </s:form>
      

  2.   

    public String save() throws IOException{
    String savePath = ServletActionContext.getServletContext().getRealPath("\\upload");
    File file = new File(savePath,imgFileName);
    byte[] buff = new byte[1024];
    int len = 0;
    FileInputStream fis = new FileInputStream(img);
    FileOutputStream fos = new FileOutputStream(file);

    while((len = fis.read(buff))>0){
    fos.write(buff);
    }
    fos.close();
    fis.close();
    return "";
    }
      

  3.   

    </action>
    <action name="product" class="productaction">
    <result name="productlist">productlist.jsp</result>
    <result name="detailproduct">detailproduct.jsp</result>
    <result name="index">index.jsp</result>
    <result name="manage">manageProduct.jsp</result>
    <result name="manage1" type="redirectAction">product!manage.action</result>
    <result name="go">addProduct.jsp</result>
    </action>
      

  4.   

    配置文件问题,class 要写全路径名
      

  5.   

    有用到spring吗?如果有在spring中配置productaction对应的bean,否则在struts2的配置文件中配置productaction类的全路径;