URL encode the parameter names as well as the values, use a StringBuffer.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@1261 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: InvocationContext.java,v 1.4 2003/10/13 17:40:10 eric Exp $
|
||||
// $Id: InvocationContext.java,v 1.5 2003/10/13 17:52:27 ray Exp $
|
||||
//
|
||||
// samskivert library - useful routines for java programs
|
||||
// Copyright (C) 2001 Michael Bayne
|
||||
@@ -111,16 +111,19 @@ public class InvocationContext extends VelocityContext
|
||||
*/
|
||||
public String encodeAllParameters ()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
Enumeration e = _req.getParameterNames();
|
||||
|
||||
String url = "";
|
||||
while (e.hasMoreElements()) {
|
||||
String param = (String)e.nextElement();
|
||||
url += StringUtil.blank(url) ? param : "&" + param;
|
||||
url += "=" + StringUtil.encode(_req.getParameter(param));
|
||||
if (buf.length() > 0) {
|
||||
buf.append('&');
|
||||
}
|
||||
String param = (String) e.nextElement();
|
||||
buf.append(StringUtil.encode(param));
|
||||
buf.append('=');
|
||||
buf.append(StringUtil.encode(_req.getParameter(param)));
|
||||
}
|
||||
|
||||
return url;
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
protected HttpServletRequest _req;
|
||||
|
||||
Reference in New Issue
Block a user