Spring3 整合 Mybatis3
Spring3 整合 Mybatis3
这两天,项目需要使用spring+ibatis,于是去网上下载了,结果发现和之前我用的版本变化不小,整了两天才将功能实现,不敢怠慢,赶紧写份博客记录一下。
首先是依赖的库:

接着是web.xml的配置,这里,我使用的是Spring3 MVC
import java.util.HashMap;import java.util.List;import java.util.Map;import javax.inject.Inject;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.ResponseBody;import com.log.bean.KeywordExportPVDataBean;import com.log.bean.dao.KeywordExportPVDao;@Controllerpublic class KeywordInfoController {@InjectKeywordExportPVDao keywordExportPVDao;@RequestMapping(value="getKeywordExportPVData.do", method=RequestMethod.POST)@ResponseBodypublic Object getKeywordExportPVInfo(KeywordExportPVDataBean req_data ){List<KeywordExportPVDataBean> rows = keywordExportPVDao.getKeywordExportPVList(req_data);String records = keywordExportPVDao.getKeywordExportPVTotalNumByDate(req_data);Map<String,Object> result = new HashMap<String,Object> ();result.put("records", Integer.valueOf(records));result.put("total", Integer.valueOf(records)/req_data.getRows() + 1);result.put("rows", rows);return result;}}- 2楼fover717昨天 16:48
- 可能是因为要和Spring集成,所以代码多了一些。
- 1楼luju5昨天 01:18
- 看了mybatis代码还是不够精简啊,特别是和jpa相比