JFinal使用笔记3-注册和登陆功能开发记录

当前访客身份:游客 [  登陆 |  加入开源中国 ]
 
当前访客身份: 游客 [  登陆 |  加入开源中国 ]
 
  • 开源项目做者
选择,坚持,勤奋
博客分类
最新评论
访客统计
  • 4
  • 22
  • 4
  • 4
  • 33612

原 JFinal使用笔记3-注册和登陆功能开发记录

发表于3年前(2013-03-12 00:10)   阅读( 2174) | 评论(4) 5人收藏此文章, 我要收藏
1
一、用户表的ID设置为字符串型,非空,在保存的时候须要给ID赋值。 
?
1
2
3
User user=getModel(User. class );
user.set( "id" , UUID.randomUUID().toString());
user.save();
二、登陆时须要从前台得到用户名密码而后去数据库查询是否存在 
?
1
2
3
4
String name=getPara( "user.name" );
String password=getPara( "user.password" );
List<User> l=User.dao.find( "select * from user where name='"
                  +name+ "' and password='" +password+ "'" );

三、保存和移除用户信息到session中php

?
1
2
3
4
//保存session
getSession().setAttribute( "username" , name);
//移除session
getSession().removeAttribute( "username" );
四、前台使用jstl来判断显示不一样的内容 
?
1
2
3
4
5
6
7
8
< c:if test = "${sessionScope.username!=null}" >
     < a href = '/user/userInfo.jsp' >欢迎 ${sessionScope.username}</ a >
     < span ></ span >< a href = '/user/logout' >注销</ a >
</ c:if >
< c:if test = "${sessionScope.username==null}" >
     < a href = '/user/login.jsp' >登陆</ a >
     < span ></ span >< a href = '/user/register.jsp' >注册</ a >
</ c:if >

jstl只有if没有else,因此用了两个if。分支多的时候能够用下面的标签html

?
1
2
3
4
5
6
7
8
9
10
11
< c:choose >
  < c:when test = "${condition1}" >
    condition1为true
  </ c:when >
  < c:when test = "${ condition2}" >
    condition2为true
  </ c:when >
  < c:otherwise >
    condition1和condition2都为false
  </ c:otherwise >
</ c:choose >

 

五、servlet api
http://tomcat.apache.org/tomcat-5.5-doc/servletapi/ 前端

分享到:  1
声明:OSCHINA 博客文章版权属于做者,受法律保护。未经做者赞成不得转载。
最新热门职位
更多开发者职位上  开源中国·招聘
 

评论4

  • 1楼:Smile月光 Android 发表于 2013-03-12 06:59 回复此评论
    主要的呢。。。。
     
  • 2楼:土龙 发表于 2013-03-12 09:25 回复此评论

    引用来自“panfanglin”的评论

    主要的呢。。。。java

    不知道你想看什么?我写的jfinal使用笔记主要记录我对jfinal的熟悉过程。关于注册和登陆的功能还在作,其余东西我会慢慢补上去。
     
  • 3楼:greatddk 发表于 2013-06-14 14:59 回复此评论
    'or 'a'='a,登陆成功!
     
  • 4楼:土龙 发表于 2013-06-14 15:04 回复此评论

    引用来自“greatddk”的评论

    'or 'a'='a,登陆成功!mysql

    谢谢提醒,安全问题几乎没有考虑,会尽快补上漏洞。很是感谢。
     
土龙

插入: 表情 开源软件linux

关闭相关文章阅读
 
相关文章
相关标签/搜索