在jsp中打印会话属性 [英] Print session attributes in jsp
本文介绍了在jsp中打印会话属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的网络应用已准备就绪,但我只是想添加一个用户名为标题的小下拉菜单。这是我的jsp代码:
My webapp is ready but I just wanted to add a little dropdown menu with the username as title. This is my jsp code:
<i class="icon-user"></i>
<%
session.getAttribute("name");
%>
<span class="caret"></span>
它是sais
会话不能已解决
9: <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
10: <i class="icon-user"></i>
11: <%
12: session.getAttribute("name");
13: %>
14: <span class="caret"></span>
15: </a>
因为我已登录而有会话。
There is a session because I'm logged in.
亲切的问候,
推荐答案
您可以使用EL,这是JSP中的首选。
You can use EL, which is prefered in JSP.
<c:out value="${sessionScope.name}"/>
或者 name
值是否为HTML安全,你可以使用
Or if the name
value is HTML safe, you can use
${sessionScope.name}
确保JSP是允许访问会话。
Make sure the JSP is allow access session.
<%@ page session="true" %>
要使用核心JSTL,请确保包含以下代码。
To use core JSTL, make sure the following code is included.
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
这篇关于在jsp中打印会话属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文