Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to encode the url in strut2

 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How to encode the url in strut2
as i have this url.
inscreenlist!show.action?candidate_id=<s:property value="candidate_id" />

Please help me.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you actually trying to accomplish? Do you really want to encode the string "<s:property..." or do you want the value of the candidate ID?

If the latter, it depends on how you're trying to generate the URL, so without more info, it's tough to help.

If the former, why?!>
 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to encode this .

<s:property value="candidate_id" />
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...

Do you want the tag itself in the URL, or do you want the candidate's ID in the URL (like as a parameter)?

I wrote: If the latter, ***it depends on how you're trying to generate the URL***, so without more info, it's tough to help.

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rather than going back and forth several more times, I'll just throw out some random answers, and maybe one of them will be the one you need.That's assuming candidate_id is an action property or accessible in the stack.
 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but how it will encode the url.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://struts.apache.org/2.1.6/docs/url.html

Look at the "encode" and "escapeAmp" attributes.

Have you even *tried* it to just *SEE* how the URL is encoded?!
 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi use like this

<s:url id="theUrl" action="jobapply" method="add" encode="true" escapeAmp="true" >
<s:param name="jobCode" value="jobCode" />
<s:param name="jobId" value="jobCode"/>
</s:url>
<a href="<s:property value="#theUrl"/>">Apply Online</a>

and i am getting url like this.

http://localhost:8080/cyberq/jobapply!add.action?jobCode=101&jobId=101

Still it not encoded my url values.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic