我的值如var = P q EvhE951eg / I5nz1vi / w2YpJdH v / vSPaQNg / I = 我在url中传递了这个参数 http://localhost/proj/home.jsp?var = P q EvhE951eg / I5nz1vi / w2YpJdH v / vSPaQNg / I = 现在在home.jsp中我想使用var的这个值
我在url中传递了这个参数
http://localhost/proj/home.jsp?var = P q EvhE951eg / I5nz1vi / w2YpJdH v / vSPaQNg / I =
现在在home.jsp中我想使用var的这个值.但是当我这样做时
String var = request.getParameter(“var”); var获取值
“P q EvhE951eg / I5nz1vi / w2YpJdH v / vSPaQNg / I =”注意它用空格替换.
所以任何人都可以帮我解决这个问题.
尝试编码这样的参数:class Ideone { public static void main (String[] args) throws java.lang.Exception { String param = "P+q+EvhE951eg/I5nz1vi/w2YpJdH+v/vSPaQNg/I="; System.out.printf("Orginal Param: %s\n", param); param = java.net.URLEncoder.encode(param, "utf-8"); System.out.printf("Encoded Param: %s\n", param); } }
输出:
Orginal Param: P+q+EvhE951eg/I5nz1vi/w2YpJdH+v/vSPaQNg/I= Encoded Param: P%2Bq%2BEvhE951eg%2FI5nz1vi%2Fw2YpJdH%2Bv%2FvSPaQNg%2FI%3D