StrutsRequestWrapperpublic class StrutsRequestWrapper extends HttpServletRequestWrapper
All Struts requests are wrapped with this class, which provides simple JSTL accessibility. This is because JSTL
works with request attributes, so this class delegates to the value stack except for a few cases where required to
prevent infinite loops. Namely, we don't let any attribute name with "#" in it delegate out to the value stack, as it
could potentially cause an infinite loop. For example, an infinite loop would take place if you called:
request.getAttribute("#attr.foo").
|
Constructors Summary |
---|
public StrutsRequestWrapper(HttpServletRequest req)The constructor
super(req);
|
Methods Summary |
---|
public java.lang.Object | getAttribute(java.lang.String s)Gets the object, looking in the value stack if not found
if (s != null && s.startsWith("javax.servlet")) {
// don't bother with the standard javax.servlet attributes, we can short-circuit this
// see WW-953 and the forums post linked in that issue for more info
return super.getAttribute(s);
}
ActionContext ctx = ActionContext.getContext();
Object attribute = super.getAttribute(s);
boolean alreadyIn = false;
Boolean b = (Boolean) ctx.get("__requestWrapper.getAttribute");
if (b != null) {
alreadyIn = b.booleanValue();
}
// note: we don't let # come through or else a request for
// #attr.foo or #request.foo could cause an endless loop
if (!alreadyIn && attribute == null && s.indexOf("#") == -1) {
try {
// If not found, then try the ValueStack
ctx.put("__requestWrapper.getAttribute", Boolean.TRUE);
ValueStack stack = ctx.getValueStack();
if (stack != null) {
attribute = stack.findValue(s);
}
} finally {
ctx.put("__requestWrapper.getAttribute", Boolean.FALSE);
}
}
return attribute;
|
|