提交 afd6fe90 编写于 作者: R Rob Harrop

[SPR-5927] fixed FormTag attribute clearing

上级 b18a1dc5
......@@ -423,6 +423,15 @@ public class FormTag extends AbstractHtmlElementTag {
@Override
public int doEndTag() throws JspException {
this.tagWriter.endTag();
return EVAL_PAGE;
}
/**
* Clears the stored {@link TagWriter}.
*/
@Override
public void doFinally() {
super.doFinally();
this.pageContext.removeAttribute(MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
this.pageContext.removeAttribute(COMMAND_NAME_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
if (this.previousNestedPath != null) {
......@@ -433,15 +442,6 @@ public class FormTag extends AbstractHtmlElementTag {
// Remove exposed nestedPath value.
this.pageContext.removeAttribute(NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
}
return EVAL_PAGE;
}
/**
* Clears the stored {@link TagWriter}.
*/
@Override
public void doFinally() {
super.doFinally();
this.tagWriter = null;
this.previousNestedPath = null;
}
......
......@@ -253,6 +253,16 @@ public class FormTagTests extends AbstractHtmlElementTagTests {
assertContainsAttribute(inputOutput, "type", "hidden");
}
public void testClearAttributesOnFinally() throws Exception {
this.tag.setModelAttribute("model");
getPageContext().setAttribute("model", "foo bar");
assertNull(getPageContext().getAttribute(FormTag.MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE));
this.tag.doStartTag();
assertNotNull(getPageContext().getAttribute(FormTag.MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE));
this.tag.doFinally();
assertNull(getPageContext().getAttribute(FormTag.MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE));
}
private String getFormTag(String output) {
int inputStart = output.indexOf("<", 1);
int inputEnd = output.lastIndexOf(">", output.length() - 2);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册