189 8069 5689

Spring+Struts2+Mybatis

spring-framework-3.2.4.RELEASE jar 包:

创新互联网站建设提供从项目策划、软件开发,软件安全维护、网站优化(SEO)、网站分析、效果评估等整套的建站服务,主营业务为网站制作、成都网站设计重庆App定制开发以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。创新互联深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

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

内容:


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">
  student management
 
 
contextConfigLocation
classpath:applicationContext.xml
 

   
    org.springframework.web.util.Log4jConfigListener
 

 
 
    log4jConfigLocation
    classpath:log4j.properties
 

 

 org.springframework.web.context.ContextLoaderListener

 
 
  

          

                   characterEncoding

                   org.springframework.web.filter.CharacterEncodingFilter

                   

                             encoding

                             UTF-8

                   

                   

                             forceEncoding

                             true

                   

          

          

                    characterEncoding

                   /*

          


 
    struts2
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
 

 
    struts2
    /*
 

  
 
    5
 

  
 
    /index.jsp
 

  

-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------

applicationContext.xml

位置:src/applicationContext.xml

内容:


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
            ">


   
     
   
 
    
   
     
   

    
     
            class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
         
            classpath:jdbc.properties  
       
 
   
 
      
     
            class="org.springframework.jdbc.datasource.DriverManagerDataSource">  
         
            ${jdbc.driver}  
       
 
         
            ${jdbc.url}  
       
 
         
            ${jdbc.user}  
       
 
         
            ${jdbc.pwd}  
       
 
   
 
    
      
       
           
           
   
 
    
      
          
   
 
    
    
   
        
       
   
    
  
   
     
                  rollback-for="java.lang.Exception" no-rollback-for="java.lang.RuntimeException"/>
                  rollback-for="java.lang.RuntimeException" />
                  rollback-for="java.lang.Exception" />
       
       
       
     

   

  
       
       
     
   




 

-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------

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

内容:

 
  
 
     
         
   
 
     
         
   
 
 

-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------

struts.xml文件

文件位置:/src/struts.xml

文件内容:




"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">



      
   
        
       
            /index.jsp
       

        
   

       

-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------

studentMapper.xml

文件位置:/src/studentMapper.xml

文件内容:

 
  
 
      
     
         
            
   
 
      
     
    
     
        insert into student(STUNO,NAME) values( #{stuNo},#{name})
   
 
 

-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------

/WebContent/index.jsp

文件位置:/WebContent/index.jsp,其它文件位置:/WebContent/WEB-INF/page/

文件内容:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




Hello World


   


       


       ${message}
       


   

   
   

      请输入姓名:
 
 
 
   

   

-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------

文件: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 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 getStudents() {

    List 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


当前标题:Spring+Struts2+Mybatis
转载注明:http://cdxtjz.cn/article/jdosjo.html

其他资讯