开发者

Sending & in query String

开发者 https://www.devze.com 2022-12-12 10:39 出处:网络
From first.jsp I am sending some parameters to result.jsp as - <a href=\"result.jsp?itemId=${itemId}&itemName=${item.itemName}&itemCode=${item.itemCode}\')\">Show Items</a>

From first.jsp I am sending some parameters to result.jsp as -

<a href="result.jsp?itemId=${itemId}&itemName=${item.itemName}&itemCode=${item.itemCode}')">Show Items</a>

Here ${item.itemName} can have values like "food & stationary". When item name contains an "&", I am not able to get whole value on result page, its printing only "food". Is there any way (in JSTL or any) so that I can encode "&". I know if I would convert "&" to "%26" then this would cor开发者_StackOverflow中文版rect.


Use JSTL's c:url and c:param for that. Basic example:

<a href="<c:url value="result.jsp">
    <c:param name="itemId" value="${itemId}" />
    <c:param name="itemName" value="${item.itemName}" />
    <c:param name="itemCode" value="${item.itemCode}" />
</c:url>">Show Items</a>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号