如何执行此 JSP 代码 <%= session.getAttribute("attributeName") %>在表达语言中
如何用表达式语言执行此 JSP 代码 <%= session.getAttribute("attributeName") %>
内容类似于 ${blabla}
忘了说我实际上尝试了 ${sessionScope.attributeName}
,顺便说一句,属性值是一个字符串,由 设置>session.setAttribute("attributeName", "EditSession123");
并检查值是否发送正确,我创建了一个 jsp 1.0 文件并使用 <%= session.getAttribute("attributeName") %>
正在工作,但是当我使用 JSP 2.0 时,什么也没有出现。
我开始质疑我的标题定义?它是从 Eclipse 自动生成的
<?xml version="1.0" encoding="UTF-8" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
<jsp:directive.page contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" session="false"/>
<jsp:output doctype-root-element="html"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
omit-xml-declaration="true" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Insert title here</title>
</head>
<body>
hello ${sessionScope.attributeName}
${pageContext.servletContext.serverInfo}
</body>
</html>
</jsp:root>
How to do this JSP code <%= session.getAttribute("attributeName") %>
in Expression Language
where stuff goes like ${blabla}
Forgot to say that I actually tried the ${sessionScope.attributeName}
, btw the attribute value is a String and was set by session.setAttribute("attributeName", "EditSession123");
and to check on that the value was sent right I created a jsp 1.0 file and used <%= session.getAttribute("attributeName") %>
which was working but when I used JSP 2.0 nothing appears.
I'm beginning to question my header definitions ? it's auto generated from Eclipse
<?xml version="1.0" encoding="UTF-8" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
<jsp:directive.page contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" session="false"/>
<jsp:output doctype-root-element="html"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
omit-xml-declaration="true" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Insert title here</title>
</head>
<body>
hello ${sessionScope.attributeName}
${pageContext.servletContext.serverInfo}
</body>
</html>
</jsp:root>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ops, :S session 设置为 false,我应该仔细阅读 eclipse 生成的代码,
ops, :S session is set as false, I should have read the eclipse generated code carefully,