|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2016 the original author or authors. |
|
|
|
* Copyright 2002-2023 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -66,6 +66,8 @@ public abstract class AbstractTemplateView extends AbstractUrlBasedView { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set whether all request attributes should be added to the |
|
|
|
* Set whether all request attributes should be added to the |
|
|
|
* model prior to merging with the template. Default is "false". |
|
|
|
* model prior to merging with the template. Default is "false". |
|
|
|
|
|
|
|
* <p>Note that some templates may make request attributes visible |
|
|
|
|
|
|
|
* on their own, e.g. FreeMarker, without exposure in the MVC model. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setExposeRequestAttributes(boolean exposeRequestAttributes) { |
|
|
|
public void setExposeRequestAttributes(boolean exposeRequestAttributes) { |
|
|
|
this.exposeRequestAttributes = exposeRequestAttributes; |
|
|
|
this.exposeRequestAttributes = exposeRequestAttributes; |
|
|
|
@ -73,7 +75,7 @@ public abstract class AbstractTemplateView extends AbstractUrlBasedView { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set whether HttpServletRequest attributes are allowed to override (hide) |
|
|
|
* Set whether HttpServletRequest attributes are allowed to override (hide) |
|
|
|
* controller generated model attributes of the same name. Default is "false", |
|
|
|
* controller generated model attributes of the same name. Default is "false" |
|
|
|
* which causes an exception to be thrown if request attributes of the same |
|
|
|
* which causes an exception to be thrown if request attributes of the same |
|
|
|
* name as model attributes are found. |
|
|
|
* name as model attributes are found. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -122,11 +124,11 @@ public abstract class AbstractTemplateView extends AbstractUrlBasedView { |
|
|
|
String attribute = en.nextElement(); |
|
|
|
String attribute = en.nextElement(); |
|
|
|
if (model.containsKey(attribute) && !this.allowRequestOverride) { |
|
|
|
if (model.containsKey(attribute) && !this.allowRequestOverride) { |
|
|
|
throw new ServletException("Cannot expose request attribute '" + attribute + |
|
|
|
throw new ServletException("Cannot expose request attribute '" + attribute + |
|
|
|
"' because of an existing model object of the same name"); |
|
|
|
"' because of an existing model object of the same name"); |
|
|
|
} |
|
|
|
} |
|
|
|
Object attributeValue = request.getAttribute(attribute); |
|
|
|
Object attributeValue = request.getAttribute(attribute); |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
exposed = exposed != null ? exposed : new LinkedHashMap<>(); |
|
|
|
exposed = (exposed != null ? exposed : new LinkedHashMap<>()); |
|
|
|
exposed.put(attribute, attributeValue); |
|
|
|
exposed.put(attribute, attributeValue); |
|
|
|
} |
|
|
|
} |
|
|
|
model.put(attribute, attributeValue); |
|
|
|
model.put(attribute, attributeValue); |
|
|
|
@ -144,11 +146,11 @@ public abstract class AbstractTemplateView extends AbstractUrlBasedView { |
|
|
|
String attribute = en.nextElement(); |
|
|
|
String attribute = en.nextElement(); |
|
|
|
if (model.containsKey(attribute) && !this.allowSessionOverride) { |
|
|
|
if (model.containsKey(attribute) && !this.allowSessionOverride) { |
|
|
|
throw new ServletException("Cannot expose session attribute '" + attribute + |
|
|
|
throw new ServletException("Cannot expose session attribute '" + attribute + |
|
|
|
"' because of an existing model object of the same name"); |
|
|
|
"' because of an existing model object of the same name"); |
|
|
|
} |
|
|
|
} |
|
|
|
Object attributeValue = session.getAttribute(attribute); |
|
|
|
Object attributeValue = session.getAttribute(attribute); |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
exposed = exposed != null ? exposed : new LinkedHashMap<>(); |
|
|
|
exposed = (exposed != null ? exposed : new LinkedHashMap<>()); |
|
|
|
exposed.put(attribute, attributeValue); |
|
|
|
exposed.put(attribute, attributeValue); |
|
|
|
} |
|
|
|
} |
|
|
|
model.put(attribute, attributeValue); |
|
|
|
model.put(attribute, attributeValue); |
|
|
|
|