boot客户管理系统--第一天:查询列表

教材来自于黑马出的<>,根据最后一章项目实例,自己重新做的一个合同管理系统。

3.10:实现简单的列表查询功能,很多功能如增删改,page和数据字典功能都已删减。

 一、创建持久化类

在com.itheima.core.po包中,根据相应的数据库表创建客户持久类和数据字典持久化类:

package com.itheima.core.po;

import java.util.Date;

public class Hetong {
	private Integer ht_id;
	private String ht_name;
	private String payby;
	private Integer cust_id;
	private String cust_name;	
	private Double money;
	private Date create_time;
	private String state;
	public String getCust_name() {
		return cust_name;
	}
	public void setCust_name(String cust_name) {
		this.cust_name = cust_name;
	}
	public Integer getHt_id() {
		return ht_id;
	}
	public void setHt_id(Integer ht_id) {
		this.ht_id = ht_id;
	}
	public String getHt_name() {
		return ht_name;
	}
	public void setHt_name(String ht_name) {
		this.ht_name = ht_name;
	}
	public String getPayby() {
		return payby;
	}
	public void setPayby(String payby) {
		this.payby = payby;
	}
	public Integer getCust_id() {
		return cust_id;
	}
	public void setCust_id(Integer cust_id) {
		this.cust_id = cust_id;
	}
	public Double getMoney() {
		return money;
	}
	public void setMoney(Double money) {
		this.money = money;
	}
	public Date getCreate_time() {
		return create_time;
	}
	public void setCreate_time(Date create_time) {
		this.create_time = create_time;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	
}

 

二、实现客户DAO层接口以及映射文件

在com.itheima.core.dao包中,创建HetongDao接口

package com.itheima.core.dao;

import java.util.List;

import com.itheima.core.po.Hetong;

public interface HetongDao {
	public List selectHetongList(Hetong ht);
	
	
}

创建对应的映射文件HetongDao.xml




	
	
	
	

四.创建数据字典以及客户的service层接口实现类

HetongService

package com.itheima.core.service;

import java.util.List;

import com.itheima.common.utils.Page;
import com.itheima.core.po.Hetong;

public interface HetongService {
	public List findHetongList();
}

HetongServiceImpl

package com.itheima.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.itheima.common.utils.Page;
import com.itheima.core.dao.HetongDao;
import com.itheima.core.po.Hetong;
import com.itheima.core.service.HetongService;

@Service("hetongService")
public class HetongServiceImpl implements HetongService {
	
	@Autowired
	private HetongDao hetongDao;
	public List findHetongList(){
		Hetong ht=new Hetong();
		
		List hetongs=
				hetongDao.selectHetongList(ht);
		
		return hetongs;
		
	}	
	
}

  注:这里HetongServiceImpl与源文件已经有很大区别。1.由于未使用Page类(如page,rows)且链接中无需传输数据字典的相应值(如 custSource、custIndustry、custLevel),函数参数为空        2.,直接返回List对象,未进行result的封装

 

五.创建客户控制器类CustomerController

package com.itheima.core.web.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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.itheima.core.po.Hetong;
import com.itheima.core.service.HetongService;

@Controller
public class HetongController {
	
	@Autowired
	private HetongService hetongService;
	
	@RequestMapping(value="/hetong/list.action")
	public String list(Model model){
		List hetongs=         //返回的是List<>
				hetongService.findHetongList();
		
		model.addAttribute("page",hetongs);
		
		return "hetong";
		
	}
	
}

这边相比原书里的代码,又有很大不同。1.函数传参值里只保留了model(注:得明确函数参数里的值表示链接里的值)

2.返回的是List而非Page

 

六.引入自定义标签文件

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="itheima" uri="http://itheima.com/common/"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() 
	                   + ":" + request.getServerPort() + path + "/";
%>



	
	合同管理-BootCRM
	
	
	
	
	
	
	
	
	
	
	
	


七.启动测试

链接至:http://localhost:8080/bootSSM/hetong/list.action

boot客户管理系统--第一天:查询列表_第1张图片

-->PAUSING ENDING

 

 

你可能感兴趣的:(项目开发之BOOT客户管理系统)