0

i am trying to send some parameter in jsp request parameter which contains special character like '#' Ex:

http://localhost:8080/studentenrollmentsystem/editenrolment?id=3&course=C#&name=YASHIKA&dob=1986-12-22 00:00:00.0

In the spring controller when i try to access the parameter named course it gives only C in respect of C# plus the name parameter is not captured. please help how can i implement this functionality properly.

nikhilgupta86
  • 472
  • 3
  • 15
  • 1
    possible duplicate of [How to escape Hash character in URL](http://stackoverflow.com/questions/5007352/how-to-escape-hash-character-in-url) – Uooo Jan 15 '14 at 08:33
  • i know i have to add %23 for # in url, but my question was how to convert it into such form. Is there any tag lib which can help me. – nikhilgupta86 Jan 15 '14 at 08:52

1 Answers1

1

Use the <spring:url> tag.

Specify the taglib directive at the top of your JSP (if not already specified):

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

And then you can use it something like this:

<spring:url value="http://localhost:8080/studentenrollmentsystem/editenrolment?id=3&course={course}&name=YASHIKA&dob=1986-12-22 00:00:00.0">
    <spring:param name="course" value="C#"/>
</spring:url>

Splitting out the course as a <spring:param> will ensure it gets escaped - and so the full URL will look like:

http://localhost:8080/studentenrollmentsystem/editenrolment?id=3&course=C%23&name=YASHIKA&dob=1986-12-22 00:00:00.0

More info on the tag library here.

Will Keeling
  • 22,055
  • 4
  • 51
  • 61