<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="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/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<context-param>
<param-name>contextConfigLocationparam-name>
<param-value>classpath:applicationContext_a_dataSource.xml,classpath:applicationContext_c_transaction.xml,classpath:applicationContext_d_mybatis.xmlparam-value>
context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>
listener>
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListenerlistener-class>
listener>
<servlet>
<servlet-name>springDispatcherServletservlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>
<init-param>
<param-name>contextConfigLocationparam-name>
<param-value>classpath:applicationContext_e_springmvc.xmlparam-value>
init-param>
<load-on-startup>1load-on-startup>
servlet>
<servlet-mapping>
<servlet-name>springDispatcherServletservlet-name>
<url-pattern>/url-pattern>
servlet-mapping>
<filter>
<filter-name>HiddenHttpMethodFilterfilter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilterfilter-class>
filter>
<filter-mapping>
<filter-name>HiddenHttpMethodFilterfilter-name>
<url-pattern>/*url-pattern>
filter-mapping>
<welcome-file-list>
<welcome-file>index.jspwelcome-file>
welcome-file-list>
web-app>
applicationContext_e_springmvc.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
">
<context:component-scan base-package="com.finance">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
context:component-scan>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
bean>
beans>
applicationContext_a_dataSource.xml
<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:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
">
<context:property-placeholder location="classpath:config.properties" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${driverClassName}" />
<property name="url" value="${url}" />
<property name="username" value="${userName}" />
<property name="password" value="${password}" />
bean>
beans>
applicationContext_c_transaction.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
">
<context:component-scan base-package="com.finance">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
context:component-scan>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
bean>
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<task:annotation-driven executor="asyncExecutor" />
<task:executor id="asyncExecutor" pool-size="100-10000" queue-capacity="10" />
beans>
applicationContext_d_mybatis.xml
<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:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:mybatis-config.xml" />
<property name="typeAliasesPackage"
value="
com.finance.manager.agreement.models
" />
bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage"
value="
com.finance.manager.agreement.mapper
" />
bean>
beans>
mybatis-config.xml
<configuration>
<settings>
<setting name="cacheEnabled" value="false" />
<setting name="lazyLoadingEnabled" value="false" />
<setting name="aggressiveLazyLoading" value="false" />
<setting name="multipleResultSetsEnabled" value="true" />
<setting name="useColumnLabel" value="true" />
<setting name="useGeneratedKeys" value="true" />
<setting name="autoMappingBehavior" value="FULL" />
<setting name="defaultExecutorType" value="SIMPLE" />
<setting name="defaultStatementTimeout" value="25000" />
<setting name="logImpl" value="LOG4J"/>
<setting name="callSettersOnNulls" value="true"/>
settings>
configuration>
config.properties
#dev
driverClassName = oracle.jdbc.driver.OracleDriver
url = jdbc:oracle:thin:@XXX.XXX.XXX.XX:51521/XXXXXX
userName = XXXXXX
password = XXXXXX
maxActive = 40
maxIdle = 5
defaultAutoCommit = false
timeBetweenEvictionRunsMillis = 3600000
minEvictableIdleTimeMillis = 3600000
interfacePath = http://127.0.0.1:8080/javaservice
AgreementTemplateMapper.xml
<mapper namespace="com.finance.manager.agreement.mapper.AgreementTemplateMapper">
<resultMap id="BaseResultMap" type="com.finance.manager.agreement.models.AgreementTemplate">
<id column="ID" jdbcType="VARCHAR" property="id" />
<result column="AGREEMENT_NO" jdbcType="VARCHAR" property="agreementNo" />
<result column="AGREEMENT_NAME" jdbcType="VARCHAR" property="agreementName" />
<result column="AGREEMENT_CONTENT" jdbcType="VARCHAR" property="agreementContent" />
<result column="AGREEMENT_PRINTCONTENT" jdbcType="VARCHAR" property="agreementPrintcontent" />
<result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime" />
<result column="IS_ENABLED" jdbcType="VARCHAR" property="isEnabled" />
<result column="SAVEPATH" jdbcType="VARCHAR" property="savepath" />
resultMap>
<sql id="Base_Column_List">
ID, AGREEMENT_NO, AGREEMENT_NAME, AGREEMENT_CONTENT, AGREEMENT_PRINTCONTENT,
UPDATE_TIME, IS_ENABLED, SAVEPATH
sql>
<select id="queryAgreementTemplateList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from base_agreement_template
select>
mapper>
AgreementTemplateController.java
package com.finance.manager.agreement.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import com.finance.manager.agreement.models.AgreementTemplate;
import com.finance.manager.agreement.service.AgreementTemplateService;
@Controller
@RequestMapping(value="/agreement")
public class AgreementTemplateController {
@Autowired
private AgreementTemplateService agreementTemplateService;
/**
* http://localhost:8080/finance/agreement/agreementTemplateList
* @param request
* @param response
* @return
*/
@RequestMapping(value="/agreementTemplateList")
public String list(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
List agreementTemplateList = agreementTemplateService.queryAgreementTemplateList();
modelMap.put("agreementTemplateList", agreementTemplateList);
return "/agreement/agreementTemplateList";
}
}
AgreementTemplateMapper.java
package com.finance.manager.agreement.mapper;
import java.util.List;
import com.finance.manager.agreement.models.AgreementTemplate;
public interface AgreementTemplateMapper {
List queryAgreementTemplateList();
}
AgreementTemplate.java
package com.finance.manager.agreement.models;
import java.util.Date;
public class AgreementTemplate {
private String id;
private String agreementNo;
private String agreementName;
private String agreementContent;
private String agreementPrintcontent;
private Date updateTime;
private String isEnabled;
private String savepath;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAgreementNo() {
return agreementNo;
}
public void setAgreementNo(String agreementNo) {
this.agreementNo = agreementNo;
}
public String getAgreementName() {
return agreementName;
}
public void setAgreementName(String agreementName) {
this.agreementName = agreementName;
}
public String getAgreementContent() {
return agreementContent;
}
public void setAgreementContent(String agreementContent) {
this.agreementContent = agreementContent;
}
public String getAgreementPrintcontent() {
return agreementPrintcontent;
}
public void setAgreementPrintcontent(String agreementPrintcontent) {
this.agreementPrintcontent = agreementPrintcontent;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getIsEnabled() {
return isEnabled;
}
public void setIsEnabled(String isEnabled) {
this.isEnabled = isEnabled;
}
public String getSavepath() {
return savepath;
}
public void setSavepath(String savepath) {
this.savepath = savepath;
}
}
AgreementTemplateServiceImpl.java
package com.finance.manager.agreement.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.finance.manager.agreement.mapper.AgreementTemplateMapper;
import com.finance.manager.agreement.models.AgreementTemplate;
import com.finance.manager.agreement.service.AgreementTemplateService;
@Service
public class AgreementTemplateServiceImpl implements AgreementTemplateService {
@Autowired
private AgreementTemplateMapper agreementTemplateMapper;
@Override
public List queryAgreementTemplateList() {
return agreementTemplateMapper.queryAgreementTemplateList();
}
}
AgreementTemplateService.java
package com.finance.manager.agreement.service;
import java.util.List;
import com.finance.manager.agreement.models.AgreementTemplate;
public interface AgreementTemplateService {
List queryAgreementTemplateList();
}
agreementTemplateList.jsp
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html lang="en">
<head>
<title>title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
head>
<body>
<div>
<div>
<table border="1" cellpadding="10" cellspacing="0">
<thead>
<tr>
<th>合同模板编号th>
<th>合同模板名称th>
<th>是否启用th>
<th>修改时间th>
tr>
thead>
<c:if test="${empty agreementTemplateList}">
<tr>
<td style="text-align:center;"><font style="font-size:15px;">查询无数据font>td>
tr>
c:if>
<c:forEach items="${agreementTemplateList}" var="agreementTemplate">
<tr>
<input type="hidden" name="agreementNo" value="${agreementTemplate.agreementNo}"/>
<td style="text-align:center;">${agreementTemplate.agreementNo}td>
<td style="text-align:center;">${agreementTemplate.agreementName}td>
<td style="text-align:center;"><c:if test="${agreementTemplate.isEnabled eq '1'}">是c:if><c:if test="${agreementTemplate.isEnabled eq '0'}">否c:if>td>
<td style="text-align:center;"><fmt:formatDate value="${agreementTemplate.updateTime}" pattern="yyyy-MM-dd HH:mm:ss"/>td>
tr>
c:forEach>
table>
div>
div>
body>
html>
http://localhost:8080/finance/agreement/agreementTemplateList