Search code examples
jspxhtmlstruts2jspx

use struts tags inside attributes in jspx files


I have some old jsp code that uses the struts tags inside attributes, like this:

<link href="<s:url value='/styles/layout.css'/>" 
  rel="stylesheet" type="text/css" media="all"/>

I can't get this to work in jspx files though. Is there a good alternative to sort of get the same functionality without too much clutter?


Solution

  • Try this

        <c:set var="myUrl"><s:url value='/styles/layout.css'/></c:set>
        <link href="${myUrl}"/>
    

    You may also want to try this form, but I cannot really remember if it works:

        <s:url value='/styles/layout.css' var="anUrl"/>
        <link href="${anUrl}"/>