如何在HTML页面用EL表达式接受JSP页面session中传过来的值?

不是取时间~~~~

假如有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}
这个挺简单的呀,你只要稍为看下书很容易学的。
温馨提示:答案为网友推荐,仅供参考
第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>

还有不懂的地方,可以直接找我聊本回答被网友采纳