lift的初级使用
2015-12-20 00:00
204 查看
现在做了一个登陆界面,初步总结了一下前后台的关系
现在Boot里面配置login页面的siteMap
Menu("Login") / "login", login.html被放在了webapp下面
前台的login.html 似乎需要被类
<div id="loginpage" class="lift:surround?with=dsdd&at=content">的div包起来,最重要的是这个div的class,它让这个div下面的内容被lift:surround包了起来,with后面是一个页面,at的是一个id,但我的dsdd是随便写的,也可以起作用,但去掉with和at就不行,初步猜想,div下面的内容,引用的关于lift的东西,比如:
<form class="lift:LoginForm?form=post">,都是需要
<div id="loginpage" class="lift:surround?with=dsdd&at=content">才能成功起作用的,可能我的分析是错误的,但目前只能这么设想了,后台的loginForm,里面有登陆判断的流程:
form表单的内容是:
如果登陆失败,就在最后加一个提醒,目前只能用这个笨办法来告诉用户,你的用户名和密码错误了,上一个截图,
登陆前:
admin2是个默认值,是可以登陆的
修改用户名,让它失败,登陆失败后
登陆成功当然就直接跳转了
本文出自 “沐浴心情” 博客,请务必保留此出处http://lj3331.blog.51cto.com/5679179/1020916
现在Boot里面配置login页面的siteMap
Menu("Login") / "login", login.html被放在了webapp下面
前台的login.html 似乎需要被类
<div id="loginpage" class="lift:surround?with=dsdd&at=content">的div包起来,最重要的是这个div的class,它让这个div下面的内容被lift:surround包了起来,with后面是一个页面,at的是一个id,但我的dsdd是随便写的,也可以起作用,但去掉with和at就不行,初步猜想,div下面的内容,引用的关于lift的东西,比如:
<form class="lift:LoginForm?form=post">,都是需要
<div id="loginpage" class="lift:surround?with=dsdd&at=content">才能成功起作用的,可能我的分析是错误的,但目前只能这么设想了,后台的loginForm,里面有登陆判断的流程:
object LoginForm { def render(in: NodeSeq): NodeSeq = { var nodes=new Queue[NodeSeq] nodes += in // use a Scala for-comprehension to evaluate each parameter for { r <- S.request if r.post_? // make sure it's a post name <- S.param("name") // get the name field passwd <- S.param("passwd") // get the age field } { // if everything goes as expected, // display a notice and send the user // back to the home page S.notice("Name: " + name) S.notice("Age: " + passwd) if (User.authenticate(name, passwd) != None) S.redirectTo("/") else{ nodes += <div> <span class="label label-warning"> Hi,你的用户名或密码不正确 !!</span> </div> } } // pass through the HTML if we don't get a post and // all the parameters <div> {nodes} </div> } }
form表单的内容是:
<form class="lift:LoginForm?form=post"> 用户名: <input type="text" id="name" placeholder="用户名:" class="input-large" value="admin2" name="name"> <br> 密 码: <input type="password" id="passwd" placeholder="密 码: " class="input-large" value="123456" name="passwd"> <br> <br> <button type="submit" class="btn btn-primary">登 录</button> <button type="reset" class="btn btn-primary">重 置</button> </form>
如果登陆失败,就在最后加一个提醒,目前只能用这个笨办法来告诉用户,你的用户名和密码错误了,上一个截图,
登陆前:
admin2是个默认值,是可以登陆的
修改用户名,让它失败,登陆失败后
登陆成功当然就直接跳转了
本文出自 “沐浴心情” 博客,请务必保留此出处http://lj3331.blog.51cto.com/5679179/1020916
相关文章推荐
- 5个常见可用性错误和解决方案
- Windows下Scala环境搭建
- C#实现windows form拷贝内容到剪贴板的方法
- extjs form textfield的隐藏方法
- C#实现简单的Login窗口实例
- C#实现在Form里面内嵌dos窗体的方法
- form身份验证通过后,只能用FormsAuthentication.RedirectFromLoginPage
- form.submit()不能提交表单的错误原因及解决方法
- Chrome Form多次提交表单问题的解决方法
- jquery.form.js实现将form提交转为ajax方式提交的方法
- jquery中$(#form :input)与$(#form input)的区别
- jQuery实现数秒后自动提交form的方法
- jquery text,radio,checkbox,select操作实现代码
- JQUERY获取form表单值的代码
- Oracle Form中COMMIT的概述及使用技巧
- JSP避免Form重复提交的三种方案
- Windows7下安装Scala 2.9.2教程
- Javascript和Java获取各种form表单信息的简单实例
- jquery form表单序列化为对象的示例代码
- jquery实现ajax提交form表单的方法总结