Search code examples
javaformsstruts2tagsstruts

Forward slashed removed in form id


I am using Struts2(2.3.14) and a forward slash character included in a variable created in the java server-side code is being escaped to _ after using it inside an struts form tag.

The code (JSP):

<div class="activetab" id="sub_${mytable}">
    <s:form id="%{mytable}" onsubmit="return go('%{mytable}');">

Transforms into the html:

<div class="activetab" id="sub_changePassword/execute">
    <s:form id="changePassword_execute" onsubmit="return go('changePassword/execute');">

Don't understand why I get "changePassword_execute" in the ID attribute instead of "changePassword/execute" ... (other attributes seem to be fine).

id="${myTable}" is not possible as $ is not a valid wildcard within the form id attribute.

It's strange, Any thoughts?


Solution

  • A slash is not a valid DOM ID character:

    I'd have to double-check, but it's probably the form tag converts illegal ID characters into underscores.