package com.qcby.service;
import com.qcby.model.Account;
import java.util.List;
/**
* 账户业务层接口
*/
public interface AccountService {
// 查询所有
public List findAll();
//增添账户信息
public int insert(Account account);
//修改账户信息
public int update(Account account);
//删除账户信息
public int delete(Integer id);
}
package com.qcby.service.impl;
import com.qcby.mapper.AccountMapper;
import com.qcby.model.Account;
import com.qcby.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 业务层实现类
* ssm整合业务层接口
*/
@Service
public class AccountServiceImpl implements AccountService {
@Autowired
private AccountMapper accountMapper;
/**
* 查询所有账户信息
* @return
*/
@Override
public List findAll() {
System.out.println("业务层执行了!!!");
List accountList = accountMapper.findAll();
return accountList;
}
@Override
public int insert(Account account) {
System.out.println("新增业务层执行了!!!");
int i = accountMapper.insert(account);
return i;
}
@Override
public int update(Account account) {
System.out.println("修改业务层执行了!!!");
int i = accountMapper.update(account);
return i;
}
@Override
public int delete(Integer id) {
System.out.println("删除业务层执行了!!!");
int i = accountMapper.delete(id);
return i;
}
}
package com.qcby.controller;
import com.qcby.model.Account;
import com.qcby.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
@Controller
@RequestMapping("/account")
public class AccountController {
// 注入
@Autowired
private AccountService accountService;
/**
* 查询所有
* @return
*/
@RequestMapping("/findAll.do")
public ModelAndView findAll(){
System.out.println("表现层:查询所有的账号...");
// 调用service对象的方法
List list = accountService.findAll();
ModelAndView mv = new ModelAndView();
mv.setViewName("res");
return mv;
}
}
4、Spring整合MyBatis框架
1. 搭建和测试MyBatis的环境
编写AccountMapper.xml映射配置文件
insert into account(name,money) values(#{name},#{money})
update account set name = #{name},money=#{money} where id = #{id}
delete from account where id = #{id}
2.编写AccountMapper接口
package com.qcby.mapper;
import com.qcby.model.Account;
import java.util.List;
/**
* ssm整合持久层接口
* 实现查询所有的账户信息
*/
public interface AccountMapper {
// 查询所有
public List findAll();
//新增
public int insert(Account account);
//更新
public int update(Account account);
//删除
public int delete(Integer id);
}
// 多态, 在JAVA中是这样用的, 其实在PHP当中可以自然消除, 因为参数是动态的, 你传什么过来都可以, 不限制类型, 直接调用类的方法
abstract class Tiger {
public abstract function climb();
}
class XTiger extends Tiger {
public function climb()
jQuery.extend({
handleError: function( s, xhr, status, e ) {
// If a local callback was specified, fire it
if ( s.error ) {
s.error.call( s.context || s, xhr, status, e );
}
always 总是
rice 水稻,米饭
before 在...之前
live 生活,居住
usual 通常的
early 早的
begin 开始
month 月份
year 年
last 最后的
east 东方的
high 高的
far 远的
window 窗户
world 世界
than 比...更
最近使用mybatis.3.1.0时无意中碰到一个问题:
The errors below were detected when validating the file "mybatis-3-mapper.dtd" via the file "account-mapper.xml". In most cases these errors can be d