spring-framework-3.2.4.RELEASE jar 包:
創(chuàng)新互聯(lián)網(wǎng)站建設(shè)提供從項(xiàng)目策劃、軟件開發(fā),軟件安全維護(hù)、網(wǎng)站優(yōu)化(SEO)、網(wǎng)站分析、效果評(píng)估等整套的建站服務(wù),主營(yíng)業(yè)務(wù)為網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì),重慶App定制開發(fā)以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。創(chuàng)新互聯(lián)深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
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
-----------------------------------------------------------默默無(wú)聞的分割線-----------------------------------------------------------
web.xml (從Struts2文件夾拷貝)
位置:/WEB-INF/web.xml
內(nèi)容:
<?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>
-----------------------------------------------------------默默無(wú)聞的分割線-----------------------------------------------------------
applicationContext.xml
位置:src/applicationContext.xml
內(nèi)容:
<?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>
<!--配置數(shù)據(jù)源屬性文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:jdbc.properties</value>
</property>
</bean>
<!--配置數(shù)據(jù)源 -->
<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>
<!-- 開始事務(wù)配置 -->
<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>
<!-- 結(jié)束事務(wù)配置 -->
</beans>
-----------------------------------------------------------默默無(wú)聞的分割線-----------------------------------------------------------
jdbc.properties文件
位置:/src/jdbc.properties
內(nèi)容:
jdbc.driver = oracle.jdbc.driver.OracleDriver
jdbc.url = jdbc:oracle:thin:@127.0.0.1:1521:orcl
jdbc.user =
jdbc.pwd = 123456
-----------------------------------------------------------默默無(wú)聞的分割線-----------------------------------------------------------
log4j.properties文件
位置:/src/log4j.properties
內(nèi)容:
log4j.properties文件
位置:/src/log4j.properties
內(nèi)容:
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
-----------------------------------------------------------默默無(wú)聞的分割線-----------------------------------------------------------
mybatis_config.xml文件
位置:/src/mybatis_config.xml
內(nèi)容:
<?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>
-----------------------------------------------------------默默無(wú)聞的分割線-----------------------------------------------------------
struts.xml文件
文件位置:/src/struts.xml
文件內(nèi)容:
<?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>
-----------------------------------------------------------默默無(wú)聞的分割線-----------------------------------------------------------
studentMapper.xml
文件位置:/src/studentMapper.xml
文件內(nèi)容:
<?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>
-----------------------------------------------------------默默無(wú)聞的分割線-----------------------------------------------------------
/WebContent/index.jsp
文件位置:/WebContent/index.jsp,其它文件位置:/WebContent/WEB-INF/page/
文件內(nèi)容:
<%@ 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">
請(qǐng)輸入姓名:
<input name="student.stuNo" type="text"/>
<input name="student.name" type="text"/>
<input type="submit" value = "提交"/>
</form>
</body>
</html>
-----------------------------------------------------------默默無(wú)聞的分割線-----------------------------------------------------------
文件:HelloWorldAction.java
位置:src/com/shenzhen/management/action/HelloWorldAction.java
內(nèi)容:
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;
}
}
-----------------------------------------------------------默默無(wú)聞的分割線-----------------------------------------------------------
文件:StudentDaoImpl.java
位置:/src/com/shenzhen/management/dao/impl/StudentDaoImpl.java
內(nèi)容:
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);
}
}
-----------------------------------------------------------默默無(wú)聞的分割線-----------------------------------------------------------
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
新聞標(biāo)題:Spring+Struts2+Mybatis
本文路徑:http://jinyejixie.com/article20/jdosjo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、企業(yè)建站、網(wǎng)站制作、、外貿(mào)建站、網(wǎng)站改版
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
移動(dòng)網(wǎng)站建設(shè)知識(shí)