栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringMVC mybatis整合实例代码详解

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringMVC mybatis整合实例代码详解

MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBatis 。

一、逆向工程生成基础信息










word="jalja">























public static void main(String[] arhs) throws Exception{ List warnings = new ArrayList(); boolean overwrite = true; File configFile = new File("src.main.resources/generator.xml"); ConfigurationParser cp = new ConfigurationParser(warnings); Configuration config = cp.parseConfiguration(configFile); DefaultShellCallback callback = new DefaultShellCallback(overwrite); MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings); myBatisGenerator.generate(null); }

二、springMVC与Mybatis整合 各个配置文件

1.项目结构

2、各个文件的核心代码

a.web.xml

 
 
 
index.jsp 
 

contextConfigLocation
 classpath:spring/applicationContext-*.xml 

 
org.springframework.web.context.ContextLoaderListener 
 
 
log4jConfigLocation 
classpath:log4j.properties 
 
 
log4jRefreshInterval 
3000 
 
 
org.springframework.web.util.Log4jConfigListener 
 


SpringEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter

encoding
UTF-8


forceEncoding
true



SpringEncodingFilter
*.do
 
 
 
springMvc 
org.springframework.web.servlet.DispatcherServlet 
 

contextConfigLocation 
classpath:spring/springmvc.xml 
 
1 
 
 
springMvc 




我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号