ssh的整合

来源:互联网 发布:java for循环 编辑:程序博客网 时间:2024/05/01 09:40

通过mvc的形式对ssh进行整合

如果对ssh的整合过程不是很懂的,可以参考下我这篇博文(手把手教你组建ssh)

http://blog.csdn.net/arryluo123/article/details/53948527

对ssh的整合所注意的几点:

1,在web.xml中加入

<context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><filter><filter-name>struts</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts</filter-name><url-pattern>/*</url-pattern></filter-mapping>
2,在Struts中加入<constant name="struts.objectFactory" value="spring"></constant>,不然会出错;


//还有一点就是在applicationContext中的action的bean中记得设置 scope="prototype">


因为此属性是的设置是可以创建多个实例,默认不写就是单例,当你有多张表时,查询出来就会导致数据都是一样的。

demo的下载



package com.shandian.dao;import java.util.List;import com.shandian.bean.Users;public interface IUserInfoDao {// 登录模块Users login(Users users);// 全查List<Users> getAll();// 添加void add(Users users);// 删除void delete(int id);// 通过ID获取当前的对象Users getUsers(int id);// 更新数据void update(Users users);}

demo的下载

0 0
原创粉丝点击