是否有可能采用HTML 5标签并创建像 <form:canvas path="" id="" title=""/>
这样的弹簧窗体标签,就像<form:input path="" id="" title=""/>
一样。如何实现这一点,我是否需要添加到我的spring-form.tld副本中?SpringMVC自定义窗体标签
我很困惑,我可以如何创建这个有人可以解释这一点。我想这样做,所以我可以从弹簧绑定中获益,从而形成元素。
是否有可能采用HTML 5标签并创建像 <form:canvas path="" id="" title=""/>
这样的弹簧窗体标签,就像<form:input path="" id="" title=""/>
一样。如何实现这一点,我是否需要添加到我的spring-form.tld副本中?SpringMVC自定义窗体标签
我很困惑,我可以如何创建这个有人可以解释这一点。我想这样做,所以我可以从弹簧绑定中获益,从而形成元素。
因为春天自定义标签看到 Create a custom tag library which extends the Spring tag library 按照你的问题,以下是序列春天FormTag如何工作
.doStartTag()RequestContextAwareTag类的方法被称为先上。
AbstractFormTag类的.doStartTagInternal()方法在第二次被调用。
。第三次调用FormTag的writeTagContent(TagWriter tagwriter)方法。
现在让我们按照这个调用顺序并扩展FormTag类。 对于1和2,调用顺序是相同的。但是在CustomFormTag扩展FormTag时,3将调用CustomFormTag的writeTagContent。
所以我们的代码将
public class CustomFormTag extends FormTag
{
public CustomFormTag()
{
}
protected int writeTagContent(TagWriter tagWriter)
throws JspException
{
int result = super.writeTagContent(tagWriter);
writeOptionalAttribute(tagWriter, "testattribute", getTestAttribute());
return result;
}
//getter and setter for testattribute.
上调用代码super.writeTagContent(tagWriter);
它调用FormTag类的writeTagContent方法。
protected int writeTagContent(TagWriter tagWriter)
throws JspException
{
this.tagWriter = tagWriter;
tagWriter.startTag("form"); // form tag is here so we can not change it with canvas
writeDefaultAttributes(tagWriter);
tagWriter.writeAttribute("action", resolveAction());
writeOptionalAttribute(tagWriter, "method", getMethod());
writeOptionalAttribute(tagWriter, "target", getTarget());
writeOptionalAttribute(tagWriter, "enctype", getEnctype());
writeOptionalAttribute(tagWriter, "accept-charset", getAcceptCharset());
writeOptionalAttribute(tagWriter, "onsubmit", getOnsubmit());
writeOptionalAttribute(tagWriter, "onreset", getOnreset());
writeOptionalAttribute(tagWriter, "autocomplete", getAutocomplete());
tagWriter.forceBlock();
String modelAttribute = resolveModelAttribute();
pageContext.setAttribute(MODEL_ATTRIBUTE_VARIABLE_NAME, modelAttribute, 2);
pageContext.setAttribute(COMMAND_NAME_VARIABLE_NAME, modelAttribute, 2);
previousNestedPath = (String)pageContext.getAttribute("nestedPath", 2);
pageContext.setAttribute("nestedPath", modelAttribute + ".", 2);
return 1;
}
所以你不能延伸春天标签库Spring MVC的范围内改变形式的画布。 。您可以编写不扩展弹簧标签库的自定义标签