Spring - Expression Language

springmvc

// 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?

  1. requestScope
  2. param: This object contains the URL parameters and post parameters as well.
  3. sessionScope
  4. paramValues
  5. 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 ${ … }

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License