spring-framework-3.2.4.RELEASE jar 包:
spring-aop-3.2.4.RELEASE.jar
spring-aspects-3.2.4.RELEASE.jar
spring-beans-3.2.4.RELEASE.jar
spring-context-3.2.4.RELEASE.jar
spring-core-3.2.4.RELEASE.jar
spring-expression-3.2.4.RELEASE.jar
spring-jdbc-3.2.4.RELEASE.jar
spring-orm-3.2.4.RELEASE.jar
spring-tx-3.2.4.RELEASE.jar
spring-web-3.2.4.RELEASE.jar
spring-context-support-3.2.4.RELEASE.jar
下载地址:https://repo.spring.io/webapp/#/artifacts/browse/tree/search/
quick/eyJzZWFyY2giOiJxdWljayIsInF1ZXJ5Ijoic3ByaW5nLWZyYW1ld29yayJ9
struts-2.3.24.1 jar 包:
commons-fileupload-1.3.1.jar
commons-io-2.2.jar
commons-lang3-3.2.jar
commons-logging.jar
commons-logging-1.1.3.jar
freemarker-2.3.22.jar
javassist-3.11.0.GA.jar
ognl-3.0.6.jar
struts2-core-2.3.24.1.jar
struts2-spring-plugin-2.3.4.1.jar
aopalliance-1.0.jar
xwork-core-2.3.24.1.jar
下载地址:http://archive.apache.org/dist/struts/2.3.24/
mybatis-3.3.0 jar包:
log4j-1.2.17.jar
mybatis-3.3.0.jar
下载地址:https://github.com/mybatis/mybatis-3/releases
其它jar包:
ojdbc14.jar
mybatis-spring-1.2.1.jar
servlet-api-2.5-6.1.9.jar
aspectjweaver.jar
wsdl4j.jar
-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------
web.xml (从Struts2文件夹拷贝)
位置:/WEB-INF/web.xml
内容:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:javaee="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="starter" version="2.4">
<javaee:display-name>student management</javaee:display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter>
<filter-name>characterEncoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>5</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------
applicationContext.xml
位置:src/applicationContext.xml
内容:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p ="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
">
<bean id = "studentService" class="com.shenzhen.management.service.impl.StudentServiceImpl">
<property name="studentDao" ref="studentDao"></property>
</bean>
<bean id = "studentDao" class="com.shenzhen.management.dao.impl.StudentDaoImpl">
<property name="sqlSessionTemplate" ref="sqlSessionTemplate"></property>
</bean>
<!--配置数据源属性文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:jdbc.properties</value>
</property>
</bean>
<!--配置数据源 -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>${jdbc.driver}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.user}</value>
</property>
<property name="password">
<value>${jdbc.pwd}</value>
</property>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis_config.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
<!-- 开始事务配置 -->
<bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<tx:advice id="studentTxAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="delete*" propagation="REQUIRED" read-only="false"
rollback-for="java.lang.Exception" no-rollback-for="java.lang.RuntimeException"/>
<tx:method name="add*" propagation="REQUIRED" read-only="false"
rollback-for="java.lang.RuntimeException" />
<tx:method name="update*" propagation="REQUIRED" read-only="false"
rollback-for="java.lang.Exception" />
<tx:method name="find*" propagation="SUPPORTS"/>
<tx:method name="get*" propagation="SUPPORTS"/>
<tx:method name="select*" propagation="SUPPORTS"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="pcut" expression="execution(public * com.shenzhen.management.service.*.*(..))" />
<aop:advisor pointcut-ref="pcut" advice-ref="studentTxAdvice" />
</aop:config>
<!-- 结束事务配置 -->
</beans>
-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------
jdbc.properties文件
位置:/src/jdbc.properties
内容:
jdbc.driver = oracle.jdbc.driver.OracleDriver
jdbc.url = jdbc:oracle:thin:@127.0.0.1:1521:orcl
jdbc.user =
jdbc.pwd = 123456
-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------
log4j.properties文件
位置:/src/log4j.properties
内容:
log4j.properties文件
位置:/src/log4j.properties
内容:
log4j.rootLogger=debug,stdout,logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern= %d %p [%c] - <%m>%n
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=C:/\student.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %l %F%p %m%n
log4j.appender.logfile.Encoding=utf-8
log4j.category.org.springframework=WARN
log4j.category.org.springframework=WARN
log4j.category.org.apache.struts2=WARN
log4j.category.com.opensymphony.xwork2=WARN
log4j.category.com.ibatis=WARN
log4j.category.com.mybatis=WARN
log4j.category.org.apache.ibatis.logging.commons=WARN
-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------
mybatis_config.xml文件
位置:/src/mybatis_config.xml
内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<typeAlias alias="student" type="com.shenzhen.management.pojo.Student"/>
</typeAliases>
<mappers>
<mapper resource="/studentMapper.xml"/>
</mappers>
</configuration>
-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------
struts.xml文件
文件位置:/src/struts.xml
文件内容:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.i18n.encoding" value="UTF-8"/>
<package name="default" extends="struts-default">
<action name="helloWorld" class="com.shenzhen.management.action.HelloWorldAction">
<result name="success">/index.jsp</result>
</action>
</package>
</struts>
-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------
studentMapper.xml
文件位置:/src/studentMapper.xml
文件内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shenzhen.management">
<resultMap type="student" id="studentMap">
<result property="stuNo" column="STUNO"/>
<result property="name" column="NAME"/>
</resultMap>
<select id="getStudents" parameterType="String" resultMap="studentMap">
select * from student
</select>
<insert id="addStudent" parameterType="student">
insert into student(STUNO,NAME) values( #{stuNo},#{name})
</insert>
</mapper>
-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------
/WebContent/index.jsp
文件位置:/WebContent/index.jsp,其它文件位置:/WebContent/WEB-INF/page/
文件内容:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello World</title>
</head>
<body>
<div>
<h2>
${message}
</h2>
</div>
<form action="helloWorld.action" method="get">
请输入姓名:
<input name="student.stuNo" type="text"/>
<input name="student.name" type="text"/>
<input type="submit" value = "提交"/>
</form>
</body>
</html>
-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------
文件:HelloWorldAction.java
位置:src/com/shenzhen/management/action/HelloWorldAction.java
内容:
public class HelloWorldAction implements Action {
private Student student = null;
private String message = "";
private StudentService studentService = null;
@Override
public String execute() throws Exception {
this.message = student.getName();
List<Student> students = studentService.getStudents();
return SUCCESS;
}
}
-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------
文件:StudentDaoImpl.java
位置:/src/com/shenzhen/management/dao/impl/StudentDaoImpl.java
内容:
import java.util.List;
import org.mybatis.spring.SqlSessionTemplate;
import com.shenzhen.management.dao.StudentDao;
import com.shenzhen.management.pojo.Student;
public class StudentDaoImpl implements StudentDao{
private SqlSessionTemplate sqlSessionTemplate
;
public SqlSessionTemplate getSqlSessionTemplate() {
return sqlSessionTemplate;
}
public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
this.sqlSessionTemplate = sqlSessionTemplate;
}
@Override
public List<Student> getStudents() {
List<Student> students = null;
students = sqlSessionTemplate.selectList("com.shenzhen.management.getStudents");
return students;
}
@Override
public void addStudent(Student student) {
sqlSessionTemplate.insert("com.shenzhen.management.addStudent",student);
}
}
-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------
JDK:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
tomcat: http://tomcat.apache.org/download-70.cgi#7.0.69
eclipse: http://eclipse.bluemix.net/packages/mars.2/
FileZilla
PuTTY
notepad++
SOAPUI
jd-gui.exe
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。