できません。マクロのコードを見てください。
#**
* springFormInput
*
* Display a form input field of type 'text' and bind it to an attribute
* of a command or bean.
*
* @param path the name of the field to bind to
* @param attributes any additional attributes for the element (such as class
* or CSS styles or size
*
*#
#macro( springFormInput $path $attributes )
#springBind($path)
<input type="text" id="${status.expression}" name="${status.expression}"
value="$!status.value" ${attributes}#springCloseTag()
#end
したがって、ご覧のとおり、を使用すると#springFormInput("command.name" 'id="myid" data-zaza="test"')
実際に次のように生成されます。
<input type="text" id="name" id="myid" data-zaza="test" />
ただし、velocityは重複したIDを消去し、最初の(id="name"
)のみを残します。
この「消去」動作は、テストを実行すると明らかになります。たとえば、手作業で宣言します。
<input type="text" id="testA" id="testB" id="testC" name="myTest" value="test!">
生成されたHTMLには次のようなものがあります。
<input type="text" id="testA" name="myTest" value="test!">
別の方法として、マクロコードを明示的に使用して、必要なものを生成できます。
#springBind("command.name")
<input type="text" id="myid" name="${status.expression}"
value="$!status.value" data-zaza="test"#springCloseTag()
${status.expression}
マクロに$!status.value
設定されている#springBind
ので、気にしないでください。