程序猿全敏的gravatar头像
程序猿全敏 2016-02-03 15:09:34

ssh框架开发整合实现用户简单登陆demo,适合ssh初学者学习

那时候一直没法ssh的素材。这个东西给我的印象就是一开始不会,后来就感觉写代码不需要思考什么了,这个包括搭建框架就7分钟写完。直接写出来,现在我就贴一点核心的代码

dao的实现

public boolean checkAdmin(String userName, String password) {
		boolean T=true;
		List list;
		list=this.getHibernateTemplate().find("from Admin where userName='"+userName+"' and password='"+password+"'");
		if(list.size()>0){
			return T;
		}
		return !T;
	}

这个就是先匹配,如果有的话就是true没有就是false。

再看Action

public String checkAdmin(){
		if(adminService.checkAdmin(admin.getUserName(), admin.getPassword())){
			return "index";
		}
		return "login";
	}

得到返回的值,如果是true就跳到index页面,否则到登陆页面、

注册那些都是soesy啦。新手一定要看看啊!

ssh框架开发整合实现用户简单登陆demo,适合ssh初学者学习

这是登陆失败的情况

ssh框架开发整合实现用户简单登陆demo,适合ssh初学者学习

这是成功的情况

ssh框架开发整合实现用户简单登陆demo,适合ssh初学者学习

如果你是要注册的话就是dao的实现层这么写

public void addAdmin(Admin admin) {
		this.getHibernateTemplate().save(admin);	
	}

其他的删除的话都蛮简单,你也可以写hql语句

代码整体结构。

ssh框架开发整合实现用户简单登陆demo,适合ssh初学者学习


打赏

文件名:scool.rar,文件大小:13455.496K 下载
  • /
      • /scool
        • /scool/.classpath
        • /scool/.myhibernatedata
        • /scool/.mymetadata
        • /scool/.mystrutsdata
        • /scool/.project
          • /scool/.settings
            • /scool/.settings/org.eclipse.jdt.core.prefs
        • /scool/.springBeans
        • /scool/admin.sql
        • /scool/hibernate.reveng.xml
          • /scool/src
            • /scool/src/applicationContext.xml
最代码最近下载分享源代码列表最近下载
女王不该在山炮村养花  LV8 2023年4月13日
莫回头  LV8 2022年5月19日
漫长的白日梦  LV8 2021年12月8日
mocker  LV6 2021年6月28日
1973356987  LV13 2021年6月16日
hashjaaa  LV4 2021年1月7日
z_wl318  LV1 2020年12月9日
zackery  LV9 2020年6月9日
tiger081  LV11 2020年6月4日
hefenyuan91  LV11 2020年6月3日
最代码最近浏览分享源代码列表最近浏览
WBelong  LV7 2023年12月11日
微信网友_6698455742353408 2023年10月19日
暂无贡献等级
dododododo  LV1 2023年7月4日
3516569014  LV5 2023年5月8日
星辰xc  LV2 2023年5月7日
女王不该在山炮村养花  LV8 2023年4月13日
彩色天空  LV5 2023年4月8日
2898786964 2023年2月7日
暂无贡献等级
18102026552  LV1 2022年8月24日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友