Search code examples
htmljspstrutsanchorstruts-1

Is there a way to put html data attribute on struts html:link tag?


I have a problem where I cannot put analytic code on my struts html:link tag. The code won't render if I put a data-analytics attribute on like this:

<html:link styleClass="analytics-click"
           action="${globalSites_context}${forgotPasswordAction}"
           title="${forgotPasswordLink}"
           data-analytics='{"location":"BrandBar","description":"BrandBar forget password"}'>${forgotPasswordLink}
</html:link> 

What can I do?


Solution

  • Change code to plain HTML

    <a class="analytics-click"
       href="${globalSites_context}${forgotPasswordAction}"
       title="${forgotPasswordLink}"
       data-analytics='{"location":"BrandBar","description":"BrandBar forget password"}'>${forgotPasswordLink}
    </a>