EvalTag skips implicit variable check if VariableResolver is null (for Jetty compatibility; SPR-7096)
This commit is contained in:
parent
eb7f8309e2
commit
7355dff967
|
|
@ -19,6 +19,7 @@ package org.springframework.web.servlet.tags;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.jsp.JspException;
|
import javax.servlet.jsp.JspException;
|
||||||
import javax.servlet.jsp.PageContext;
|
import javax.servlet.jsp.PageContext;
|
||||||
|
import javax.servlet.jsp.el.VariableResolver;
|
||||||
|
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.expression.AccessException;
|
import org.springframework.expression.AccessException;
|
||||||
|
|
@ -40,6 +41,7 @@ import org.springframework.web.util.TagUtils;
|
||||||
* Supports the standard JSP evaluation context consisting of implicit variables and scoped attributes.
|
* Supports the standard JSP evaluation context consisting of implicit variables and scoped attributes.
|
||||||
*
|
*
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @author Juergen Hoeller
|
||||||
* @since 3.0.1
|
* @since 3.0.1
|
||||||
*/
|
*/
|
||||||
public class EvalTag extends HtmlEscapingAwareTag {
|
public class EvalTag extends HtmlEscapingAwareTag {
|
||||||
|
|
@ -141,8 +143,11 @@ public class EvalTag extends HtmlEscapingAwareTag {
|
||||||
|
|
||||||
private final PageContext pageContext;
|
private final PageContext pageContext;
|
||||||
|
|
||||||
|
private final VariableResolver variableResolver;
|
||||||
|
|
||||||
public JspPropertyAccessor(PageContext pageContext) {
|
public JspPropertyAccessor(PageContext pageContext) {
|
||||||
this.pageContext = pageContext;
|
this.pageContext = pageContext;
|
||||||
|
this.variableResolver = pageContext.getVariableResolver();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<?>[] getSpecificTargetClasses() {
|
public Class<?>[] getSpecificTargetClasses() {
|
||||||
|
|
@ -150,7 +155,8 @@ public class EvalTag extends HtmlEscapingAwareTag {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
|
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
|
||||||
return target == null && (resolveImplicitVariable(name) != null || this.pageContext.findAttribute(name) != null);
|
return (target == null && (resolveImplicitVariable(name) != null) ||
|
||||||
|
this.pageContext.findAttribute(name) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
|
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
|
||||||
|
|
@ -170,8 +176,11 @@ public class EvalTag extends HtmlEscapingAwareTag {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object resolveImplicitVariable(String name) throws AccessException {
|
private Object resolveImplicitVariable(String name) throws AccessException {
|
||||||
|
if (this.variableResolver == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return this.pageContext.getVariableResolver().resolveVariable(name);
|
return this.variableResolver.resolveVariable(name);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
throw new AccessException(
|
throw new AccessException(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue