MVC框架2 struts2+ibatis+spring
1、MVC框架结构
2、目录结构
3、代码
ScanInfoAction
package com.asiainfo.crm.infomanage.action;
import java.util.List;
import com.asiainfo.crm.infomanage.manger.ScanInfoManager;
import com.asiainfo.crm.infomanage.model.ScanInfo;
import com.asiainfo.crm.web.BaseActionSupport;
public class ScanInfoAction extends BaseActionSupport {
public ScanInfoManager scanInfoManager;
public ScanInfo scanInfo;
public List ssc;
public ScanInfoManager getScanInfoManager() {
return scanInfoManager;
}
public void setScanInfoManager(ScanInfoManager scanInfoManager) {
this.scanInfoManager = scanInfoManager;
}
public ScanInfo getScanInfo() {
return scanInfo;
}
public void setScanInfo(ScanInfo scanInfo) {
this.scanInfo = scanInfo;
}
public List getSsc() {
return ssc;
}
public void setSsc(List ssc) {
this.ssc = ssc;
}
public String search()throws Exception{
try {
if(null!=scanInfo){
ssc=scanInfoManager.getScanInfos(scanInfo, pageSupport);
}
} catch (Exception e) {
e.printStackTrace();
}
return "search";
}
}
ScanInfoManagerImpl
package com.asiainfo.crm.infomanage.manger;
import java.util.List;
import com.asiainfo.crm.infomanage.dao.ScanInfoDao;
import com.asiainfo.crm.infomanage.model.ScanInfo;
import com.asiainfo.crm.web.PageSupport;
public class ScanInfoManagerImpl implements ScanInfoManager {
public ScanInfoDao scanInfoDao;
public List scanInfoList;
public List getScanInfos(ScanInfo scanInfo, PageSupport pageSupport)
throws Exception {
scanInfoList=scanInfoDao.getScanInfos(scanInfo, pageSupport);
return scanInfoList;
}
public ScanInfoDao getScanInfoDao() {
return scanInfoDao;
}
public void setScanInfoDao(ScanInfoDao scanInfoDao) {
this.scanInfoDao = scanInfoDao;
}
}
ScanInfoManager
package com.asiainfo.crm.infomanage.manger;
import java.util.List;
import com.asiainfo.crm.infomanage.model.ScanInfo;
import com.asiainfo.crm.web.PageSupport;
public interface ScanInfoManager {
public List getScanInfos(ScanInfo scanInfo ,PageSupport pageSupport)throws Exception;
}
ScanInfoDaoImplIbatis
package com.asiainfo.crm.infomanage.dao;
import java.util.List;
import com.asiainfo.crm.dao.BaseDaoiBATIS;
import com.asiainfo.crm.infomanage.model.ScanInfo;
import com.asiainfo.crm.web.PageSupport;
public class ScanInfoDaoImplIbatis extends BaseDaoiBATIS implements ScanInfoDao {
public List getScanInfos(ScanInfo scanInfo, PageSupport pageSupport)
throws Exception {
Object[] obj={scanInfo};
List list=this.getPageList(obj, pageSupport, "getScanInfoCount", "getScanInfoList");
return list;
}
}
ScanInfoDao
package com.asiainfo.crm.infomanage.dao;
import java.util.List;
import com.asiainfo.crm.infomanage.model.ScanInfo;
import com.asiainfo.crm.web.PageSupport;
public interface ScanInfoDao {
public List getScanInfos(ScanInfo scanInfo ,PageSupport pageSupport)throws Exception;
}
ScanInfoSQL.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="ScanInfoSQL">
<typeAlias alias="scanInfoSQL"
type="com.asiainfo.crm.infomanage.model.ScanInfo" />
<sql id="Select_Clause">
SELECT S.DID as did ,
S.DEVICE_NUMBER as deviceNumber ,
S.IID as iid ,
S.IMAGE_NAME as imageName ,
S.IMAGE_PATH as imagePath ,
S.OPERATOR_ID as operatorId ,
S.OPERATOR_NAME as operatorName ,
S.CREATE_DATE as createDate
FROM SH_MAT_SCANINFO_HIS S
</sql>
<sql id="Where_Clause">
<dynamic prepend="where">
<isNotEmpty prepend="and" property="deviceNumber">
DEVICE_NUMBER=trim(#deviceNumber#)
</isNotEmpty>
</dynamic>
</sql>
<select id="getScanInfoCount"
parameterClass="java.util.Map" resultClass="int">
SELECT COUNT(1) FROM SH_MAT_SCANINFO_HIS
<include refid="Where_Clause" />
</select>
<select id="getScanInfoList"
parameterClass="java.util.Map"
resultClass="scanInfoSQL">
<include refid="public.oraclePageStart" />
<include refid="Select_Clause" />
<include refid="Where_Clause" />
ORDER BY S.CREATE_DATE DESC
<include refid="public.oraclePageEnd" />
</select>
</sqlMap>
sql-map-config.xml
<!-- 资料管理系统begin -->
<!-- 历史资料查询 -->
<sqlMap resource="com/asiainfo/crm/infomanage/sql/ScanInfoSQL.xml"/>
<!-- 交接管理 -->
<sqlMap resource="com/asiainfo/crm/infomanage/sql/ShMatDeliverInfoSQL.xml"/>
<!-- 日志 -->
<sqlMap resource="com/asiainfo/crm/infomanage/sql/ShMatOperateLogSQL.xml"/>
<!-- 资料交接查询 -->
<sqlMap resource="com/asiainfo/crm/infomanage/sql/ConnectSQL.xml"/>
<!-- 资料管理系统end -->
applicationContext-ibatis.xml
<!-- 历史资料查询 -->
<bean id="scanInfoDao" class="com.asiainfo.crm.infomanage.dao.ScanInfoDaoImplIbatis">
<property name="dataSource">
<ref bean="osssDataSource"/>
</property>
<property name="sqlMapClient">
<ref local="sqlMapClient"/>
</property>
</bean>
<!-- 交接 -->
<bean id="shMatDeliverInfoDao2" class="com.asiainfo.crm.infomanage.dao.ShMatDeliverInfoDaoImplIbatis">
<property name="dataSource">
<ref bean="osssDataSource"/>
</property>
<property name="sqlMapClient">
<ref local="sqlMapClient"/>
</property>
</bean>
<!-- 资料管理日志 -->
<bean id="shMatOperateLogDao" class="com.asiainfo.crm.infomanage.dao.ShMatOperateLogDaoImplIbatis">
<property name="dataSource">
<ref bean="osssDataSource"/>
</property>
<property name="sqlMapClient">
<ref local="sqlMapClient"/>
</property>
</bean>
<!-- 资料交接管理查询 -->
<bean id="connectDao" class="com.asiainfo.crm.infomanage.dao.ConnectDaoImplIbatis">
<property name="dataSource">
<ref bean="osssDataSource"/>
</property>
<property name="sqlMapClient">
<ref local="sqlMapClient"/>
</property>
</bean>
<!-- 资料管理系统end -->
applicationContext-service-query.xml
<!-- 资料管理系统begin -->
<!-- 历史资料查询 -->
<bean id="scanInfoManager" class="com.asiainfo.crm.infomanage.manger.ScanInfoManagerImpl">
<property name="scanInfoDao">
<ref bean="scanInfoDao"/>
</property>
</bean>
<!-- 交接 -->
<bean id="shMatDeliverInfoManager2" class="com.asiainfo.crm.infomanage.manger.ShMatDeliverInfoManagerImpl">
<property name="shMatDeliverInfoDao2">
<ref bean="shMatDeliverInfoDao2"/>
</property>
</bean>
<!-- 资料管理日志 -->
<bean id="shMatOperateLogManager" class="com.asiainfo.crm.infomanage.manger.ShMatOperateLogManagerImpl">
<property name="shMatOperateLogDao">
<ref bean="shMatOperateLogDao"/>
</property>
</bean>
<!-- 资料交接管理查询 -->
<bean id="connectManager" class="com.asiainfo.crm.infomanage.manger.ConnectManagerImpl">
<property name="connectDao">
<ref bean="connectDao"/>
</property>
</bean>
<!-- 资料管理系统end -->
struts-config-infomange.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="infomanage" extends="basepack" namespace="/infomanage">
<!-- -->
<action name="infomanage_*" class="com.asiainfo.crm.infomanage.action.InfoManageAction" method="{1}">
<result name="upload">/crmsh/infomanage/jsp/success.jsp</result>
</action>
<!-- 资料管理系统 历史资料查询 -->
<action name="scaninfo_*" class="com.asiainfo.crm.infomanage.action.ScanInfoAction" method="{1}">
<result name="{1}">/crmsh/infomanage/jsp/scaninfo_{1}.jsp</result>
</action>
<!-- 资料管理系统 交接管理 -->
<action name="shMatDeliverInfo_*" class="com.asiainfo.crm.infomanage.action.ShMatDeliverInfoAction" method="{1}">
<result name="{1}">/crmsh/infomanage/jsp/shMatDeliverInfo_{1}.jsp</result>
</action>
<!-- 资料管理系统 交接管理查询 -->
<action name="connect_*" class="com.asiainfo.crm.infomanage.action.ConnectAction" method="{1}">
<result name="{1}">/crmsh/infomanage/jsp/connect_{1}.jsp</result>
</action>
<!-- 资料管理系统 操作日志 -->
<action name="shMatOperateLog_*" class="com.asiainfo.crm.infomanage.action.ShMatOperateLogAction" method="{1}">
<result name="{1}">/crmsh/infomanage/jsp/shMatOperateLog_{1}.jsp</result>
</action>
</package>
</struts>
struts.xml
<!-- 资料扫描系统 -->
<include file="config_sh/struts-config-infomange.xml" />
转载于:https://www.cnblogs.com/tjpfly/archive/2011/09/04/2166833.html