title: How can I add or change params to a struts url tag?
body: <p>In struts, I'd like to have a base URL (an &lt;s:url...) set up with a some parameters (&lt;s:param...), and then either add parameters to that URL or change the values of some parameters. For example:</p>
  
  <pre>
  <code>&lt;s:url action=&quot;getSomeData&quot; id=&quot;baseDataUrl&quot;&gt;
      &lt;s:param name=&quot;someID&quot; value=&quot;%{currentID}&quot;/&gt;
  &lt;/s:url&gt;
  </code>
  </pre>
  
  <p>I can then do <code>&lt;s:property value=&quot;baseDataUrl&quot; /&gt;</code> and it'll spit out something like /getSomeData.do?someID=5. (I'm keeping the params simple for this example, but you can imagine having many more default params. For instance, the app I'm working on has 3 params that are the same for every URL, and two that change.)</p>
  
  <p>I'd like to be able to add or change parameters after defining that base URL. I'm dreaming up two approaches:</p>
  
  <pre>
  <code>&lt;s:url base=&quot;baseDataUrl&quot; id=&quot;breadUrl&quot;&gt;
      &lt;s:param name=&quot;bread&quot; value=&quot;%{&#x27;toast&#x27;}&quot;/&gt;
  &lt;/s:url&gt;
  </code>
  </pre>
  
  <p>And then <code>&lt;s:property value=&quot;breadUrl&quot; /&gt;</code> would result in /getSomeData.do?someID=5&amp;bread=toast. Another approach is to define the base URL with placeholders:</p>
  
  <pre>
  <code>&lt;s:url action=&quot;getSomeData&quot; id=&quot;baseDataUrl&quot;&gt;
      &lt;s:param name=&quot;someID&quot; value=&quot;%{currentID}&quot;/&gt;
      &lt;s:param name=&quot;bread&quot; /&gt;
      &lt;s:param name=&quot;jelly&quot; /&gt;
  &lt;/s:url&gt;
  </code>
  </pre>
  
  <p>And then fill them in when I ask for the property:</p>
  
  <pre>
  <code>&lt;s:param url=&quot;baseDataUrl&quot; name=&quot;bread&quot; value=&quot;%{&#x27;toast&#x27;}&quot;/&gt;
  &lt;s:param url=&quot;baseDataUrl&quot; name=&quot;jelly&quot; value=&quot;%{selectedJam}&quot;/&gt;
  </code>
  </pre>
  
  <p>So <code>&lt;s:property value=&quot;baseDataUrl&quot; /&gt;</code> would result in /getSomeData.do?someID=5&amp;bread=toast&amp;jelly=7.</p>
  
  <p>The docs for s:url (<a href="http://struts.apache.org/2.0.14/docs/url.html" rel="nofollow noreferrer">http://struts.apache.org/2.0.14/docs/url.html</a>) say "Dynamic Attributes Allowed: false" so I think I'm venturing into custom-tag territory. This feels like such a common use case (define a base URL with some params, and then add or change some of them) that I don't want to reinvent the wheel. Searching has yielded nothing, but maybe I'm not looking for the right thing. I'm open to a wide variety of suggestions!</p>