1

In my struts.xml I have:

<result name="Alpha" type="redirectAction">
  <param name="actionName">/page1/page2</param>
  <param name="id">$(id)</param>
</result>

And in a JSP I also have:

<s:url action="page4/page5"><s:param name="id" value="id" /></s:url>

These two code blocks are unrelated, just areas trying to achieve a similar outcome.

This all works ok but my issue is, if there is no id url parameter sent through, we just get "?id=" which looks terrible. How do I have the id removed when there is no value for it?

This is like an object context, sometimes a page will have it, sometimes a page wont have it. This is part of a test app hence the ominous page and param names.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Phish
  • 774
  • 3
  • 11
  • 27
  • 1
    See answer to this question: [Suppress empty parameters using param tag](http://stackoverflow.com/q/25796090/1700321). – Aleksandr M Feb 05 '15 at 09:47
  • @AleksandrM now why couldnt I find this one!!! Thank you for this - just testing! – Phish Feb 05 '15 at 09:48
  • It happens, don't worry. :) – Aleksandr M Feb 05 '15 at 09:49
  • BTW the issue WW-4275 mentioned in linked answer is resolved in `2.3.20`. – Aleksandr M Feb 05 '15 at 09:55
  • 1
    If you want to thank him @Phish, you could upvote the linked answer – Andrea Ligios Feb 05 '15 at 10:22
  • 1
    @AleksandrM Thanks for this, I have used this answer to resolve the issue in the struts XML however when I try to use it for the s:url tag, with or without the .toString() I get Attribute suppressEmptyParameters invalid for tag param according to TLD. Is this an out of date framework issue? – Phish Feb 05 '15 at 10:24
  • @AleksandrM dammity damn it. Thank you for general you awesomeness. – Phish Feb 05 '15 at 10:46

0 Answers0