不熟悉的知识

      首先解决的页面的排版问题:使用了一个table来列举商品的信息,注意第一行的第一列属性中有rowspan属性,这个属性用来表示该列跨几行,在下边一个列属性中有colspan是跨几列的属性值。在这个中,咱们定义了一个占据9行的一列用来显示咱们的图像,图像调用了showImage的controller方法来显示图片。style属性来设置图片的长和宽,注意该项的写法,style="width:300px;height:400px"java

<td rowspan="9" style="height:300px;width:400px;"><img alt="" src="showImage?pictureId=${commodityForm.pictureId}" style="height:300px;width:400px;"></td>sql

     

      在修改商品信息中,由于涉及到input的type为file标签,咱们须要在对应的controller中加入参数:数据库

@RequestParam(value = "file", required = false) MultipartFile fileui

@RequestParam(value = "attachments", required = false) MultipartFile attachmentsspa

      这两个参数value都是对应的input中的name属性,MultipartFile代表传入的是一个文件。在执行添加商品的service中,咱们涉及了一个select,这个sql语句是执行了从数据库中自动生成一个pictureId.它的sql文写法以下:orm

<select id="getSeq" resultClass="java.lang.Integer">图片

SELECT _nextval('commodityId')ip

</select>ci

   在service中addCommodity的写法以下:get

public boolean addCommodity(CommodityForm frm) {

Integer sequee = queryDao.executeForObject("Commodity.getSeq", null, Integer.class);

          //获得一个自增的commundityId;

String commodityId = frm.getUpdateTime().substring(0, 4) + String.format("%011d", sequee);

          //C

frm.setCommodityId(commodityId);

if (frm.getPicture().length != 0) {            //能够获得图片

frm.setPictureId(commodityId);

int picResult = updateDao.execute("Commodity.addPicture", frm);   //插入图片

if (picResult != 1) {

return false;

}

}

int result = updateDao.execute("Commodity.addCommodity", frm);//插入除图片外的其余数据

if (result == 1) {                                                            //插入成功

return true;

}

return false;                                                       //插入失败

}

相关文章
相关标签/搜索