您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。