我在此假定,你的目标是让开发商知道他们不正当地利用你的习俗。 由于在其他答复中已经提到过,你希望以不同的方式处理用户输入错误,因为在联合项目上留下的错误很可能(视配置而定)最终将用户送到应用错误的网页。
如果你能够把tag的tag头手编成法典,那么,pec在TLD中就包含一些可以做到的任择内容。
- The spec defines the
validator
element which takes a class implementing javax.servlet.jsp.tagext.TagLibraryValidator
. In practice this is somewhat complicated to use as it offers a bunch of flexibility.
- The spec also defines
tei-class
which takes a class extending TagExtraInfo
. As the JavaDoc notes:
Extra Tag Information for a Custom Tag; this class is mentioned in the
Tag Library Descriptor file (TLD). This class must be used:
- if the tag defines any scripting variables
- if the tag wants to provide translation-time validation of the tagattributes.
视共同未来方案版本而定,您需要超越isValid(
或validate(>
)方法,处理验证开发商提供的变量。
The Apache taglibs use these for validating some of their tags:
(https://github.com/javaee/jstl-api/blob/master/impl/src/main/java/org/apache/taglibs/standard/tei/ImportTEI.java)
public boolean isValid(TagData us) {
if (Util.isSpecified(us, VAR) && Util.isSpecified(us, VAR_READER))
return false;
return true;
}
OR 如果您正在使用联合执行文件P 2.0,执行<编码>validate<>code>,则其复杂程度不大,因为它能够退回一个<代码>的阿雷娜>。 玻璃鱼的例子有:
public ValidationMessage[] validate(TagData data) {
ValidationMessage[] vms = null;
TagLibraryInfo[] infos =
getTagInfo().getTagLibrary().getTagLibraryInfos();
if (infos.length != 1) {
vms = new ValidationMessage[1];
vms[0] = new ValidationMessage(null, "Wrong number of tsglibs");
}
return vms;
}