自定义 JSP 标记属性不区分大小写

Custom JSP Tag Attribute Case Insensitivity

我们的团队正在从 Web Logic 12 迁移到 Tomcat 9;我们注意到我们的自定义 JSP 标签在属性方面存在问题。属性大小写不正确(例如 "myattribute" 与 "myAttribute")。这会导致 JSP 在 Tomcat 9 中出现编译错误,但不会在 Web Logic 12 中出现。我无法共享确切的代码,但以下是我们遇到的相同模式。

Tomcat 中是否有允许 JSP 引擎允许自定义标记属性不区分大小写的设置?

标签库

<tag>
  <name>myTag</name>
  <tagclass>com.foo.MyTag</tagclass>
  <bodycontent>JSP</bodycontent>
  <info> This Tag defines a form.</info>

  <attribute>
    <name>myVar</name>
    <required>false</required>
  </attribute>
</tag>

Class

public class MyTag {
  private String myVar = "";
  public void setMyVar(String myVar) {
    this.myVar = myVar;
  }
  public String getMyVar()
  {
    return this.myVar;
  }
}

JSP

<customTag:myTag myvar="bar"/>

错误信息(或类似信息)

 org.apache.jasper.JasperException: /jsp/mypage.jsp 
   (line: [###], column: [0]) 
   Attribute [myvar] invalid for tag [myTag] according to TLD

Tag attribute区分大小写,因为Java变量

Tag attributes must be declared inside the tag element by means of an attribute element. The attribute element has three nested elements that can appear between and .

name. This is a required element that defines the case-sensitive attribute name.