11智能在线
新记
如何在HTML页面用EL表达式接受JSP页面session中传过来的值?
不是取时间~~~~
举报该文章
相关建议 推荐于2017-12-04
假如有session属性:session.setAttribute("currentUser","admin")
那么在用el表达式输出时这样写:${sessionScope.currentUser}他在页面上就会显示admin
上面这句el表达式的意思是,将session范围的,以currentUser为name的value显示出来
如果存储的value是个类对象,例如:UserVo user = new UserVo(); UserVo 中有个属性叫username,还有个叫password,
session.setAttribute("curuser",user);//存储当前登录用户的用户名和密码
取出显示user中的用户名和密码是就是这样写的:
用户名:${sessionScope.curuser.username}
密码:${sessionScope.curuser.password}
这个挺简单的呀,你只要稍为看下书很容易学的。
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/pqf2fs8q2.html
其他看法
第1个回答 2017-12-04
使用 thymeleaf 就像jstl标签库一样使用,可以让html变得和jsp一样使用
<html xmlns:th="http://www.thymeleaf.org">
Hello, <shiro:principal/>, how are you today?<shiro:hasRole name="ADMIN"><br />I'm fine, 我拥有管理员角色--
<span th:text="${username}"></span></shiro:hasRole>
</html>
第2个回答 2010-11-28
首先el表达式,只能拿到有带get开头的方法;
所有你可以先用request.setAttribute("date",new Date());
然后在返回的jsp页面上用$,就能那到服务器上的时间,
如果你仅仅只想在获得本地上的时间,你只要用js就可以获得了
<script>
var date =new Date();
//这里的date 是你打开jsp页面的 本地时间,和服务器时间是有区别的
</script>
还有不懂的地方,可以直接找我聊
本回答被网友采纳
相似回答
大家正在搜
相关问题
在纯js文件中用EL表达式获取jsp内置session对象的...
List里面放了一个对象,再将List放入session中,...
JSP中img标签里的路径使用EL表达式取后台传过来的值为空...
JSP中,EL表达式向session中取出一个attribu...
在纯js文件中用EL表达式获取jsp内置session对象的...
jsp怎么用el表达式把值显示出来?
验证码验证,后台把验证码存到session中,在jsp页面中...
jsp中 在做验证码比较时,用的是EL表达式获取sessio...