Struts2+ibatis+spring项目整合档示例.docx
《Struts2+ibatis+spring项目整合档示例.docx》由会员分享,可在线阅读,更多相关《Struts2+ibatis+spring项目整合档示例.docx(30页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、编号:时间:2021年x月x日书山有路勤为径,学海无涯苦作舟页码:第30页 共30页Struts2+ibatis+spring整合开发1. 工程结构图2. 配置文件web.xmlweb-app version=2.4 xmlns= xmlns:xsi=http:/www.w3.org/2001/XMLSchema-instance xsi:schemaLocation= index.jsp contextConfigLocation /WEB-INF/applicationContext.xml org.springframework.web.context.ContextLoaderList
2、ener struts2 org.apache.struts2.dispatcher.FilterDispatcher struts2 /* 如图:Struts.xml /success.jsp /login.jsp show.action /error.jsp update.jsp show.action /error.jsp show.action /error.jsp /list.jsp /error.jsp 如图:Struts.properties#struts.url.http.port=8080struts.devMode=truestruts.configuration.xml.
3、reload=truestruts.locale=zh_CNstruts.i18n.encoding=UTF-8struts.objectFactory=spring如图:sql-map-config.xml 如图:applicationContext.xml classpath:sql-map-config.xml 如图:3. Login.javapackage cn.hsw.action;import java.util.List;import cn.hsw.model.User;import cn.hsw.service.IUserService;import com.opensymph
4、ony.xwork2.ActionSupport;import com.opensymphony.xwork2.ModelDriven;import com.opensymphony.xwork2.Preparable;public class Login extends ActionSupport implements ModelDriven, Preparable private IUserService userService=null;private String id;private int pageIndex=1;private String pageBar;private Lis
5、t list;private User user;public void prepare()throws Exceptionif(id=null|id.length()=0)user=new User();elseuser=getUserService().getUserById(Integer.parseInt(id);public String execute()throws Exceptionif(getUserService().isLogin(user)return SUCCESS;return INPUT;public String save()throws Exceptionif
6、(getUserService().insertUser(user)return SUCCESS;return ERROR;public String edit()return SUCCESS;public String update()throws Exceptionif(getUserService().updateUser(user)return SUCCESS;return ERROR;public String delete()throws Exceptionif(getUserService().deleteUser(Integer.parseInt(id)return SUCCE
7、SS;return ERROR;public String findAllUser()throws Exceptiontry list=getUserService().getAllUser(); catch (Exception e) return SUCCESS;public String getId() return id;public void setId(String id) this.id = id;public int getPageIndex() return pageIndex;public void setPageIndex(int pageIndex) this.page
8、Index = pageIndex;public String getPageBar() return pageBar;public void setPageBar(String pageBar) this.pageBar = pageBar;public List getList() return list;public void setList(List list) this.list = list;public User getUser() return user;public void setUser(User user) this.user = user;public void se
9、tUserService(IUserService userService) this.userService = userService;public IUserService getUserService() return userService;public User getModel() / TODO Auto-generated method stubreturn user;如图:IUserDAO.javapackage cn.hsw.dao;import java.util.List;import cn.hsw.model.User;public interface IUserDA
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Struts2 ibatis spring 项目 整合 示例
限制150内