简体   繁体   中英

My link URLs are changing

In my web portal, for some users (not all), when they click to a link, the '&' characters become '+' .

For example, the link is : www.mysite.com/test.jsp?param1=test1&param2=test2 ,

Then it becomes : www.mysite.com/test.jsp?param1=test1+param2=test2

It only happens for a specific country (Brazil). My other portals with same code work correctly.

I thought to handle request with servlet and when I see "+" replace with "&" but it is not a proper solution I think..

Any idea ?

Try with JSTL core tag c:url

This tag automatically performs URL rewriting when necessary. The JSTL url tag is just an alternative method of writing the call to the response.encodeURL() method. The only real advantage the url tag provides is proper URL encoding, including any parameters specified by children param tag.

Sample code:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<c:url value="/test.jsp" var="url">
    <c:param name="param1" value="test1" />
    <c:param name="param2" value="test2" />
</c:url>

<a href="${url }">Click Here</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM