如何在表达式语言中执行此JSP代码

时间:2022-12-22 22:30:25

How to do this JSP code <%= session.getAttribute("attributeName") %> in Expression Language where stuff goes like ${blabla}

如何在表达式语言中执行此JSP代码<%= session.getAttribute(“attributeName”)%>,其中的内容类似$ {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.

忘了说我实际上尝试了$ {sessionScope.attributeName},顺便说一下属性值是一个字符串,由session.setAttribute(“attributeName”,“EditSession123”)设置;并检查值是否已发送,我创建了一个jsp 1.0文件,并使用了<%= session.getAttribute(“attributeName”)%>,但是当我使用JSP 2.0时,没有任何内容出现。

I'm beginning to question my header definitions ? it's auto generated from Eclipse

我开始质疑我的标题定义?它是从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> 

1 个解决方案

#1


0  

ops, :S session is set as false, I should have read the eclipse generated code carefully,

ops,:S session设置为false,我应该仔细阅读eclipse生成的代码,

#1


0  

ops, :S session is set as false, I should have read the eclipse generated code carefully,

ops,:S session设置为false,我应该仔细阅读eclipse生成的代码,