-
大小: 18.78MB文件類(lèi)型: .zip金幣: 1下載: 0 次發(fā)布日期: 2023-07-03
- 語(yǔ)言: Java
- 標(biāo)簽: JavaEE??SSH項(xiàng)目??
資源簡(jiǎn)介
一個(gè)簡(jiǎn)單的Javaee開(kāi)發(fā)的demo,使用了ssh框架的基本技術(shù),文件上傳等
代碼片段和文件信息
package?com.olmos.action;
import?java.io.File;
import?java.io.FileInputStream;
import?java.io.FileOutputStream;
import?java.util.List;
import?java.util.Map;
import?org.apache.struts2.ServletActionContext;
import?com.olmos.entity.Admin;
import?com.olmos.entity.Customer;
import?com.olmos.entity.Dishes;
import?com.olmos.entity.Order;
import?com.olmos.entity.Page;
import?com.olmos.service.AdminService;
import?com.olmos.service.CustomerService;
import?com.olmos.service.DishesService;
import?com.olmos.service.OrderService;
import?com.opensymphony.xwork2.ActionContext;
import?com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings(“serial“)
public?class?AdminAction?extends?ActionSupport?{
private?Page?page;
private?String?name;
private?String?password;
private?String?orderID;
private?String?state;
private?Integer?customerID;
private?Dishes?dishes;
private?AdminService?adminService;
private?DishesService?dishesService;
private?CustomerService?customerService;
private?OrderService?orderService;
private?String?title;
private?File?image;
private?String?imageFileContentType;
private?String?imageFileName;
private?String?savePath=ServletActionContext.getServletContext().getRealPath(“/pic“);
public?Dishes?getDishes()?{
return?dishes;
}
public?void?setDishes(Dishes?dishes)?{
this.dishes?=?dishes;
}
public?String?upload()?throws?Exception?{
//以服務(wù)器的文件保存地址和文件名建立上傳文件流
FileOutputStream?fos?=?new?FileOutputStream(savePath+“\\“+imageFileName);
if(image==null){
fos.close();
return?null;
}
//定義輸出流對(duì)象
FileInputStream?fis?=?new?FileInputStream(image);
System.out.println(savePath);
byte[]?buffer=?new?byte[1024];
int?len=0;
while((len=fis.read(buffer))>0){
fos.write(buffer?0?len);
}
fos.close();
fis.close();
return?imageFileName;
}
public?String?login(){
Admin?admin?=?adminService.login(name?password);
if(admin?!=?null){
//將信息放進(jìn)sesion
ActionContext.getContext().getSession().put(“admin“?admin);
return?“l(fā)ogin“;
}
ServletActionContext.getRequest().setAttribute(“message“?“賬號(hào)或密碼不正確“);
return?“l(fā)oginFail“;
}
public?String?getAllCustomer(){
List?list?=?customerService.getAllCustomer();
if(list.size()!=0){
ActionContext.getContext().put(“CustomerList“?list);
return?“getAllCustomer“;
}
??
return?“getAllCustomerFail“;
}
public?String?delCustomerById(){
boolean?b?=?customerService.delCustomerById(customerID);
if(b){
return?“delCustomerById“;
}
return?“delCustomerByIdFail“;
}
public?String?uploadDishes()?throws?Exception{
String?imagesPath?=?upload();
dishes.setImagesPath(imagesPath);
boolean?b?=?dishesService.uploadDishes(dishes);
if(b){
return?“uploadDishes“;
}else{
ServletActionContext.getRequest().setAttribute(“message“?“上傳失敗,請(qǐng)重新上傳“);
return?“uploadDishesFail“;
}
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2017-07-04?14:56??OLMOS\
?????文件????????4406??2017-07-06?10:55??OLMOS\.classpath
?????文件????????1330??2017-07-05?11:47??OLMOS\.project
?????目錄???????????0??2017-07-04?08:56??OLMOS\.settings\
?????文件?????????522??2017-07-04?08:56??OLMOS\.settings\.jsdtscope
?????文件?????????364??2017-07-04?08:55??OLMOS\.settings\org.eclipse.jdt.core.prefs
?????文件?????????551??2017-07-04?14:56??OLMOS\.settings\org.eclipse.wst.common.component
?????文件?????????414??2017-07-04?08:56??OLMOS\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件??????????49??2017-07-04?08:56??OLMOS\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件???????????6??2017-07-04?08:56??OLMOS\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????目錄???????????0??2017-07-09?16:14??OLMOS\config\
?????文件????????3012??2017-07-07?11:48??OLMOS\config\applicationContext.xm
?????文件?????????153??2017-07-04?14:59??OLMOS\config\jdbc.properties
?????目錄???????????0??2017-07-05?17:42??OLMOS\config\spring\
?????文件????????1985??2017-07-12?10:04??OLMOS\config\spring\applicationContext-action.xm
?????文件????????1503??2017-07-06?08:26??OLMOS\config\spring\applicationContext-dao.xm
?????文件????????1575??2017-07-09?19:44??OLMOS\config\spring\applicationContext-service.xm
?????目錄???????????0??2017-07-09?16:14??OLMOS\config\struts\
?????文件?????????733??2017-07-13?14:25??OLMOS\config\struts.xm
?????文件????????2276??2017-07-13?15:04??OLMOS\config\struts\struts-admin.xm
?????文件?????????977??2017-07-13?14:27??OLMOS\config\struts\struts-cart.xm
?????文件????????1227??2017-07-13?14:23??OLMOS\config\struts\struts-customer.xm
?????文件????????1003??2017-07-13?11:22??OLMOS\config\struts\struts-dishes.xm
?????文件?????????977??2017-07-13?14:26??OLMOS\config\struts\struts-order.xm
?????目錄???????????0??2017-07-05?11:18??OLMOS\src\
?????目錄???????????0??2017-07-04?08:57??OLMOS\src\com\
?????目錄???????????0??2017-07-13?10:31??OLMOS\src\com\olmos\
?????目錄???????????0??2017-07-11?16:30??OLMOS\src\com\olmos\action\
?????文件????????8282??2017-07-17?20:23??OLMOS\src\com\olmos\action\AdminAction.java
?????文件????????2025??2017-07-13?19:00??OLMOS\src\com\olmos\action\CustomerAction.java
?????文件????????3362??2017-07-14?08:07??OLMOS\src\com\olmos\action\DishesAction.java
............此處省略263個(gè)文件信息
評(píng)論
共有 條評(píng)論