资源简介
ssh2项目练手—购物网站http://blog.csdn.net/i_do_can/article/details/50524821
代码片段和文件信息
package com.cl.shopping.action;
import java.io.File;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;
import com.cl.shopping.bean.GoodTypes;
import com.cl.shopping.bean.Goods;
import com.cl.shopping.service.GoodsService;
import com.opensymphony.xwork2.ModelDriven;
public class AddgoodsAction implements ModelDriven{
private GoodsService goodsService;
private Goods goods = new Goods();
//用户头像
private File pic;
//Struts 提供的得到文件名的方式, 属性名+FileName
private String picFileName;
public void setGoodsService(GoodsService goodsService) {
this.goodsService = goodsService;
}
public String execute()
{
//获取服务器路径 D:\ JavaWeb \ apache-tomcat-7.0.30 \ webapps \s sh2shoping \ upload
String path = ServletActionContext.getServletContext().getRealPath(“/upload“);
//这个方式确实可以获得
// HttpServletRequest request = ServletActionContext.getRequest();
// String roles = request.getParameter(“goodtypes“);
//商品的分类还是获取 null
// goods.setGoodtypes();
if(pic != null){
String name = System.currentTimeMillis() + picFileName.substring(picFileName.lastIndexOf(“.“));
File savefile = new File(pathname);
try {
FileUtils.copyFile(pic savefile);
goods.setGoodspic(“upload/“+name);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
//设置默认的图片
goods.setGoodspic(“upload/0000.jpg“);
}
goodsService.saveGoods(goods);
return “success“;
}
public Goods getModel() {
// TODO Auto-generated method stub
return goods ;
}
public File getPic() {
return pic;
}
public void setPic(File pic) {
this.pic = pic;
}
public String getPicFileName() {
return picFileName;
}
public void setPicFileName(String picFileName) {
this.picFileName = picFileName;
}
};
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5496 2016-01-12 20:15 ssh2shoping\.classpath
文件 306 2016-01-08 16:33 ssh2shoping\.myme
文件 1754 2016-01-08 22:40 ssh2shoping\.project
文件 500 2016-01-08 16:33 ssh2shoping\.settings\.jsdtscope
文件 364 2016-01-08 16:33 ssh2shoping\.settings\org.eclipse.jdt.core.prefs
文件 471 2016-01-08 16:33 ssh2shoping\.settings\org.eclipse.wst.common.component
文件 252 2016-01-08 16:33 ssh2shoping\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2016-01-08 16:33 ssh2shoping\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2016-01-08 16:33 ssh2shoping\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 11841 2016-01-15 16:58 ssh2shoping\ReadMe.txt
文件 2083 2016-01-12 14:41 ssh2shoping\src\com\cl\shopping\action\AddgoodsAction.java
文件 5920 2016-01-15 09:08 ssh2shoping\src\com\cl\shopping\action\CarAction.java
文件 1933 2016-01-15 14:53 ssh2shoping\src\com\cl\shopping\action\ClassificGoodsAction.java
文件 1660 2016-01-13 22:57 ssh2shoping\src\com\cl\shopping\action\GoodBoardsAction.java
文件 4513 2016-01-15 14:25 ssh2shoping\src\com\cl\shopping\action\GoodsAction.java
文件 3673 2016-01-13 13:46 ssh2shoping\src\com\cl\shopping\action\GoodTypesAction.java
文件 7099 2016-01-15 11:09 ssh2shoping\src\com\cl\shopping\action\OrderAction.java
文件 1567 2016-01-15 10:55 ssh2shoping\src\com\cl\shopping\action\OrderDetailAction.java
文件 1087 2016-01-12 20:53 ssh2shoping\src\com\cl\shopping\action\RoleAction.java
文件 1521 2016-01-10 18:27 ssh2shoping\src\com\cl\shopping\action\SecurityCodeImageAction.java
文件 5130 2016-01-15 16:18 ssh2shoping\src\com\cl\shopping\action\UserAction.java
文件 2766 2016-01-15 16:55 ssh2shoping\src\com\cl\shopping\action\UserGoodsAction.java
文件 884 2016-01-14 14:25 ssh2shoping\src\com\cl\shopping\bean\Cart.java
文件 1471 2016-01-13 18:55 ssh2shoping\src\com\cl\shopping\bean\GoodBoards.java
文件 2127 2016-01-15 09:38 ssh2shoping\src\com\cl\shopping\bean\Goods.java
文件 888 2016-01-10 22:04 ssh2shoping\src\com\cl\shopping\bean\GoodTypes.java
文件 2274 2016-01-14 20:34 ssh2shoping\src\com\cl\shopping\bean\Order.java
文件 1476 2016-01-15 09:23 ssh2shoping\src\com\cl\shopping\bean\OrderDetail.java
文件 2031 2016-01-10 22:23 ssh2shoping\src\com\cl\shopping\bean\PageBean.java
文件 1831 2016-01-12 20:19 ssh2shoping\src\com\cl\shopping\bean\User.java
............此处省略255个文件信息
评论
共有 条评论