整理一下从前写的SSH框架的例子,供新人学习,使用到了注解的方式.
链接:https://pan.baidu.com/s/16i5dDIoDi4gOMsZfPvz6eg
提取码:pjqa
对新同学的建议:最好的学习方法是自己手动敲一遍,切不可看过别人写的,就觉得自己会做了
使用方式
1、首先将项目mywork3.rar解压,导入到myeclipse中,注意修改applicationContext.xml 中用户名、密码,jdk使用1.6以上的就可以。
解压后其目录结构如下:
2、在mysql中新建数据库mydb
3、导入SQL文件 user.sql
4、启动项目,输入http://localhost:8080/mywork3/ 即可打开页面
源码备份
web.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 5 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 6 <welcome-file-list> 7 <welcome-file>index.jsp</welcome-file> 8 </welcome-file-list> 9 <!-- 用来定位Spring XML文件的上下文位置 --> 10 <context-param> 11 <param-name>contextConfigLocation</param-name> 12 <param-value>classpath:applicationContext.xml</param-value> 13 </context-param> 14 <!-- spring监听 --> 15 <listener> 16 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 17 </listener> 18 <!-- 过滤器将 Hibernate Session 绑定到请求线程中,它将自动被 Spring 的事务管理器探测到 --> 19 <filter> 20 <filter-name>openSessionInViewFilter</filter-name> 21 <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> 22 <init-param> 23 <param-name>singleSession</param-name> 24 <param-value>false</param-value> 25 </init-param> 26 </filter> 27 <filter-mapping> 28 <filter-name>openSessionInViewFilter</filter-name> 29 <url-pattern>/*</url-pattern> 30 </filter-mapping> 31 <filter> 32 <filter-name>struts2</filter-name> 33 <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 34 </filter> 35 <filter-mapping> 36 <filter-name>struts2</filter-name> 37 <url-pattern>/*</url-pattern> 38 </filter-mapping> 39 </web-app>