資源簡介
spring+struts2+hibernate整合框架,具有user登陸、info表增刪改查功能,包結構標準,面向接口編程,具有Hibernate數據庫Junit測試類,可作為web項目架構基礎!
數據庫文件在項目WebRoot根目錄下
數據庫:Mysql
IDE: Myeclipse
服務器:Tomcat
測試絕對可用!
去瞧瞧吧。
代碼片段和文件信息
package?com.mstf.action;
import?java.util.List;
import?com.mstf.bean.Info;
import?com.mstf.service.InfoService;
import?com.opensymphony.xwork2.ActionContext;
import?com.opensymphony.xwork2.ActionSupport;
import?com.opensymphony.xwork2.ModelDriven;
@SuppressWarnings(“serial“)
public?class?InfoAction?extends?ActionSupport?implements?ModelDriven{
//用于ModelDriven填充對象入口為getModel方法
private?Info?info;
//用于spring自動注入,入口為setInfoService方法
private?InfoService?infoService;
//方法名對應info_*.action中的*通配符
public?String?list()?throws?Exception{
//調用service方法,返回從數據庫取出的數據
List?infolist=infoService.getAll();
//放入session
ActionContext.getContext().put(“infolist“?infolist);
//返回視圖,list對應struts.xml對應的jsp或action
return?“list“;
}
public?String?addUI()?throws?Exception{
return?“addUI“;
}
public?String?add()?throws?Exception{
infoService.save(info);
return?“tolist“;
}
public?String?updateUI()?throws?Exception{
Info?infos=infoService.getById(info.getId());
ActionContext.getContext().getValueStack().push(infos);
return?“updateUI“;
}
public?String?update()?throws?Exception{
Info?infos=infoService.getById(info.getId());
infos.setName(info.getName());
infos.setAge(info.getAge());
infos.setAddress(info.getAddress());
infoService.update(infos);
return?“tolist“;
}
public?String?delete()?throws?Exception{
infoService.delete(info.getId());
return?“tolist“;
}
@Override
public?Info?getModel()?{
info?=new?Info();
return?info;
}
public?InfoService?getInfoService()?{
return?infoService;
}
public?void?setInfoService(InfoService?infoService)?{
this.infoService?=?infoService;
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-10-30?21:49??HSS\
?????文件????????2676??2016-06-05?21:12??HSS\.classpath
?????目錄???????????0??2016-06-05?21:13??HSS\.myeclipse\
?????文件?????????282??2016-06-05?21:12??HSS\.myme
?????文件????????1746??2016-06-05?21:12??HSS\.project
?????目錄???????????0??2016-06-05?21:12??HSS\.settings\
?????文件?????????500??2016-06-05?21:12??HSS\.settings\.jsdtscope
?????文件?????????395??2016-06-05?21:12??HSS\.settings\org.eclipse.jdt.core.prefs
?????文件?????????447??2016-06-05?21:12??HSS\.settings\org.eclipse.wst.common.component
?????文件?????????252??2016-06-05?21:12??HSS\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件??????????49??2016-06-05?21:12??HSS\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件???????????6??2016-06-05?21:12??HSS\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????目錄???????????0??2016-06-05?21:12??HSS\src\
?????文件????????3999??2016-06-05?21:12??HSS\src\applicationContext.xm
?????目錄???????????0??2016-06-05?21:12??HSS\src\com\
?????目錄???????????0??2016-06-05?21:12??HSS\src\com\mstf\
?????目錄???????????0??2016-06-05?21:12??HSS\src\com\mstf\action\
?????文件????????1872??2016-06-05?21:12??HSS\src\com\mstf\action\InfoAction.java
?????文件????????1311??2016-06-05?21:12??HSS\src\com\mstf\action\UserAction.java
?????目錄???????????0??2016-06-05?21:12??HSS\src\com\mstf\bean\
?????文件?????????916??2016-06-05?21:12??HSS\src\com\mstf\bean\Bean.hbm.xm
?????文件?????????580??2016-06-05?21:12??HSS\src\com\mstf\bean\Info.java
?????文件????????1376??2016-06-05?21:12??HSS\src\com\mstf\bean\User.java
?????目錄???????????0??2016-06-05?21:12??HSS\src\com\mstf\service\
?????目錄???????????0??2016-06-05?21:12??HSS\src\com\mstf\service\impl\
?????文件????????1517??2016-06-05?21:12??HSS\src\com\mstf\service\impl\InfoServiceImpl.java
?????文件?????????999??2016-06-05?21:12??HSS\src\com\mstf\service\impl\UserServiceImpl.java
?????文件?????????279??2016-06-05?21:12??HSS\src\com\mstf\service\InfoService.java
?????文件?????????132??2016-06-05?21:12??HSS\src\com\mstf\service\UserService.java
?????目錄???????????0??2016-06-05?21:12??HSS\src\com\mstf\test\
?????文件????????1882??2016-06-05?21:12??HSS\src\com\mstf\test\TestUser.java
............此處省略68個文件信息
評論
共有 條評論