views:

463

answers:

1

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?

A: 

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}"/>
krosenvold
Is it then functionally impossible to use the s:url tag inside of the href-tag? There's almost no instances in this code where s:url is called more than once on a page, so that's going to create a host of one-time vars.
wds