pom.xml
4.0.0
top.maniy
ssm_maven_demo
1.0-SNAPSHOT
war
com.alibaba
druid
1.0.9
mysql
mysql-connector-java
5.1.32
org.springframework
spring-webmvc
4.1.3.RELEASE
org.springframework
spring-context
4.1.3.RELEASE
org.springframework
spring-beans
4.1.3.RELEASE
org.springframework
spring-jdbc
4.1.3.RELEASE
org.springframework
spring-aspects
4.1.3.RELEASE
org.springframework
spring-jms
4.1.3.RELEASE
org.springframework
spring-context-support
4.1.3.RELEASE
org.mybatis
mybatis
3.2.8
org.mybatis
mybatis-spring
1.2.2
com.github.miemiedev
mybatis-paginator
1.2.15
com.github.pagehelper
pagehelper
3.2.1
org.apache.commons
commons-lang3
3.3.2
org.apache.commons
commons-io
1.3.2
commons-net
commons-net
3.3
com.fasterxml.jackson.core
jackson-databind
2.4.2
junit
junit
4.12
test
org.slf4j
slf4j-log4j12
1.6.4
jstl
jstl
1.2
javax.servlet
servlet-api
2.5
provided
javax.servlet
jsp-api
2.0
provided
${project.artifactId}
org.apache.maven.plugins
maven-compiler-plugin
3.2
1.8
1.8
UTF-8
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssm?characterEncoding=utf-8
jdbc.username=root
jdbc.password=root
index
contextConfigLocation
classpath:spring/applicationContext-*.xml
org.springframework.web.context.ContextLoaderListener
encoding
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
encoding
/*
SpringMVC
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring/springmvc.xml
1
SpringMVC
/
SpringMVC
/index
package top.maniy.demo.mapper;
import java.util.List;
import top.maniy.demo.entity.Customer;
public interface CustomerMapper {
//获取全部用户
public List findAllCustomer();
}
package top.maniy.demo.service;
import top.maniy.demo.entity.Customer;
import java.util.List;
public interface CustomerService {
//获取全部用户
public List findAllCustomer();
}
package top.maniy.demo.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.maniy.demo.entity.Customer;
import top.maniy.demo.mapper.CustomerMapper;
/**
* 客户管理
* @author Admin
*
*/
@Service
@Transactional
public class CustomerServiceImpl implements CustomerService {
@Autowired
private CustomerMapper customerMapper;
//获取全部用户
public List findAllCustomer() {
return customerMapper.findAllCustomer();
}
}
package top.maniy.demo.entity;
import java.util.Date;
public class Customer {
private Long cust_id;
private String cust_name;
public Long getCust_id() {
return cust_id;
}
public void setCust_id(Long cust_id) {
this.cust_id = cust_id;
}
public String getCust_name() {
return cust_name;
}
public void setCust_name(String cust_name) {
this.cust_name = cust_name;
}
}
package top.maniy.demo.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import top.maniy.demo.entity.Customer;
import top.maniy.demo.service.CustomerService;
@Controller
public class CustomerController {
@Autowired
private CustomerService customerService;
@RequestMapping(value ="index")
public String index() {
return "index";
}
@RequestMapping(value ="/customer/list")
@ResponseBody
public List list() {
return customerService.findAllCustomer();
}
}
@RunWith(SpringJUnit4ClassRunner.class)//帮我们创建容器
//指定创建容器是使用那些配置文件
@ContextConfiguration(locations = {"classpath*:/spring/applicationContext-dao.xml","classpath*:/spring/applicationContext-service.xml"})