Spring - Expression Language
// Spring MVC - Expression language:
Implicit objects available to Expression Language:
sessionScope
headerValues
requestScope
param: This object contains the URL parameters and post parameters as well.
paramValues
Yes. We can use these implicit objects and methods inside ${ … }
${sessionScope.keyName}
${sessionScope.sessionAttributeName}
${header.host}
${requestScope.name} // equivalent to: <%= request.getAttribute("name")%>
${requestScope.bestBatsmanList[0]}
${requestScope.bestBatsmanMap.Sachin}
${requestScope.bestBatsmanMap["Sachin"]}
What is the purpose of Expression Language?
It is a server-side templating engine.
What are implicit objects available to Expression Language?
- requestScope
- param: This object contains the URL parameters and post parameters as well.
- sessionScope
- paramValues
- headerValues
What are some examples of using Expression Language?
${requestScope.bestBatsmanList[0]}
${requestScope.bestBatsmanMap.Sachin}
${requestScope.bestBatsmanMap["Sachin"]}
${sessionScope.keyName}
${header.host}
How can we get a request attribute using Expression Language?
${requestScope.name}
is equivalent to:
<%= request.getAttribute("name")%>
How can we use an attribute that was passed into our JSP?
Use the expression language:
${attributeName}
What is the syntax for using expression language?
${name}
${requestScope.name}
${sessionScope.sessionAttributeName}
Can we use the implict objects and methods inside the expression language?
Yes. We can use those implicit objects and methods inside ${ … }
page revision: 8, last edited: 23 Jun 2017 19:03