epoch mysql_Epoch开发笔记(1)后台框架搭建

本次采用前后台均采用MVC的结构思想来开发。

本地采用的extjs版本是extjs4.2,后台是struts2+spring+mybatis框架结构开发,前台是extjs4.2的MVC开发思想。开发工具是eclipse。

当前介绍一下前后台框架的搭建:

Epoch

struts2

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

config

struts-default.xml,struts-plugin.xml,../struts2/struts.xml

struts2

/*

contextConfigLocation

/WEB-INF/spring/applicationContext.xml

log4jConfigLocation

classpath:log4j.properties

encodingFilter

org.springframework.web.filter.CharacterEncodingFilter

encoding

utf-8

DruidWebStatFilter

com.alibaba.druid.support.http.WebStatFilter

exclusions

*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*

DruidWebStatFilter

/*

DruidStatView

com.alibaba.druid.support.http.StatViewServlet

DruidStatView

/druid/*

org.springframework.web.util.Log4jConfigListener

org.springframework.web.context.ContextLoaderListener

index.html

index.htm

index.jsp

default.html

default.htm

default.jsp

这是在web.xml中的配置项,DataSource数据源采用阿库巴巴的durid包,其中struts2,spring,mybatis都分别在WEB-INF下的文件进行加载。

下面是目录层次:

be6666afe9f493c6b8424f876cdff053.png

applicationContext.xml配置如下:

extjs4

struts2

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

config

struts-default.xml,struts-plugin.xml,../struts2/struts.xml

struts2

/*

contextConfigLocation

/WEB-INF/spring/applicationContext.xml

log4jConfigLocation

classpath:log4j.properties

encodingFilter

org.springframework.web.filter.CharacterEncodingFilter

encoding

utf-8

DruidWebStatFilter

com.alibaba.druid.support.http.WebStatFilter

exclusions

*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*

DruidWebStatFilter

/*

DruidStatView

com.alibaba.druid.support.http.StatViewServlet

DruidStatView

/druid/*

org.springframework.web.util.Log4jConfigListener

org.springframework.web.context.ContextLoaderListener

index.html

index.htm

index.jsp

default.html

default.htm

default.jsp

在这里引入了system下的jdbc.properties 文件作为配置。其中mybatis数据源是采用mybatis-spring-1.2.0.jar 的结合数据源。通过构造方法注入。代码需注入sqlSession进行操作。

通过import引入其他业务spring配置。

其中jdbc.properties如下:

url:jdbc:mysql://localhost:3306/epoch?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8

driverClassName:com.mysql.jdbc.Driver

username:root

password:root

filters:stat

maxActive:20

initialSize:1

maxWait:60000

minIdle:10

maxIdle:15

timeBetweenEvictionRunsMillis:60000

minEvictableIdleTimeMillis:300000

validationQuery:SELECT 'x'

testWhileIdle:true

testOnBorrow:false

testOnReturn:false

maxOpenPreparedStatements:20

removeAbandoned:true

removeAbandonedTimeout:1800

logAbandoned:true

引入的mybatis文件较为简单如下,具体引入后续讲解:

/p>

"http://mybatis.org/dtd/mybatis-3-config.dtd">

struts2文件的配置的话,采用动态加载的方式来进行,与普通方式不同,如下,在代码中加入

struts.enable.DynamicMethodInvocation 为true的配置。

/p>

"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

"http://struts.apache.org/dtds/struts-2.0.dtd">

代码根据业务层划分dao,spring,action三层架构思想。下一节介绍extjs4.2前台的目录结构。结合一个小案例进行前后台讲解。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值