unEscape JavaScript中的JavaScript转义值 [英] unEscape JavaScript escaped value in JAVA

查看:114
本文介绍了unEscape JavaScript中的JavaScript转义值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的网络服务中,我们通过JavaScript通过Java(Servlet)



设置Cookie,但是我们需要转义cookie的值,因为它可能



是否有一种透明的方式来转义(JavaScript)和再次解析(JAVA)?? / p>

感谢,
Pieter Goddijn

解决方案

获得 StringEscapeUtils Commons Lang 转义/取消转义。



在Javascript中,您可以通过 encodeURIComponent 转义,但我认为我给你的共享组件将满足你的需要。


in our web service we set a cookie through JavaScript wich we read again in Java (Servlet)

however we need to escape the value of the cookie because it may contain illegal characters such as '&' which messes up the cookie.

is there a transparent way to escape (JavaScript) and unescape again (JAVA) for this?

thanks, Pieter Goddijn

解决方案

In java you got StringEscapeUtils from Commons Lang to escape/unescape.

In Javascript you escape through encodeURIComponent, but I think the Commons component I gave to you will satisfy your needs.

这篇关于unEscape JavaScript中的JavaScript转义值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆