views:

143

answers:

2

Hi,

In my web application, I use strust2 url tag to pass parameters like id etc., For example, I use a link to delete an entity and I use param to pass the id of the entity to be deleted. And I follow this throughout my web app for adding, editing, deleting an entity.

During run time, sometimes, I don't get the params to be stored in my action's bean properties. When I see the link that is generated, I get something like

<a href='/projit1/p/discuss/viewDiscussion.action?d=11&amp;amp;amp;projid=11&amp;amp;disid=4'>

What are these amps for ? why do they sit in between the action calls (made by link via url tag actions ) ? By the time I traverse back and forth in my web app, I get 10s and 20s of amp sitting in the request URL. What is the problem here ? Please help.

A: 

I have found the problem. Hope it helps others.

I will have to set includeParams to none. It will avoid old request parameters

lakshmanan
A: 

In HTML, XHTML and XML certain characters are treated specially. The special characters used the most are less then (<) and ampersand (&). The < is only valid at the beginning of a tag, while the & is used to encode character entities (special characters, characters that can't be typed, etc.). Because & is special and can not appear as part of an attribute value it is encoded as &amp; and while it may look strange if you don't know why, the href value in your question is almost correct. In the same manor < should be encoded as &lt; to ensure correct browser behavior. Not encoding these characters MAY work but is NOT GUARANTEED to work.

The problem with your URL is with multiple amp; what this indicates is the href has been encoded multiple times. The first time & was changed to &amp; at that time another parameter was added with it's & separator. The whole URL was then encoded a second time changeing the first & to &amp;amp; and the second to &amp;. Then for some reason the URL was encoded a third time causing the first to change to &amp;amp;amp; and the second to &amp;amp;. To remove the excess amp;s you need to ensure the URL is only encoded for HTML once not multiple times.

Your resulting tag should look like this:

<a href='/projit1/p/discuss/viewDiscussion.actiond=11&amp;projid=11&amp;disid=4'>
Robert Menteer