博客信息

mvc之增删改查

发布时间:『 2019-01-27 10:24』  博客类别:自定义mvc  阅读(1031)

A、  搭建自定义mvc 框架

B、  E ntity

C、  优化baseDao (增删改的重复性代码太多)


 

BaseDao 的加强版

public int executeUpdate(String sql, String[] attrs, T t) throws SQLException, InstantiationException, IllegalAccessException, NoSuchFieldException, SecurityException{
		Connection con = DBAccess.getConnection();
		PreparedStatement pst = con.prepareStatement(sql);
		Field f = null;
		int i = 1;
		for (String attr : attrs) {
			f = t.getClass().getDeclaredField(attr);
			f.setAccessible(true);
			pst.setObject(i++, f.get(t));
		}
		return pst.executeUpdate();
	}


D、  dao 层之增删改查

 



 

E、  web


 


F、  配置action

 


 

G、  导入自定义标签库(标签助手类、tld 文件、 jsp

H、  J sp 页面

 

关键字:     mvc使用案例  

备案号:湘ICP备19000029号

Copyright © 2018-2019 javaxl晓码阁 版权所有