Warm tip: This article is reproduced from serverfault.com, please click

JSP getVariableResolver() is deprecated, what is the right way in JSP 2.2?

发布于 2012-11-27 04:02:44

I use this code but is deprecated, can you help me to port it to JSP 2.2

   <%= pageContext.getVariableResolver().resolveVariable("varName")%>
Questioner
Daniel De León
Viewed
1
Aleksander Blomskøld 2012-11-27 12:15:16

According to the Javadoc, the new way of getting the variable resolver is to do jspContext.getELContext().getELResolver(); as a PageContext is a JspContext, you could change your line to <%=pageContext.getELContext().getELResolver().resolveVariable("varName")%>.

If all you want is to resolve a variable you should probably be using EL-syntax instead: ${varName}.