HttpRequest增加getParametersToString方法
This commit is contained in:
@@ -519,8 +519,8 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
* @return cookie值
|
* @return cookie值
|
||||||
*/
|
*/
|
||||||
public String getCookie(String name, String dfvalue) {
|
public String getCookie(String name, String dfvalue) {
|
||||||
for (HttpCookie cookie : getCookies()) {
|
for (HttpCookie c : getCookies()) {
|
||||||
if (name.equals(cookie.getName())) return cookie.getValue();
|
if (name.equals(c.getName())) return c.getValue();
|
||||||
}
|
}
|
||||||
return dfvalue;
|
return dfvalue;
|
||||||
}
|
}
|
||||||
@@ -1134,6 +1134,26 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
return map0;
|
return map0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将请求参数转换成String, 字符串格式为: bean1={}&id=13&name=xxx <br>
|
||||||
|
* 不会返回null,没有参数返回空字符串
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public String getParametersToString() {
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
getParameters().forEach((k, v) -> {
|
||||||
|
if (sb.length() > 0) sb.append('&');
|
||||||
|
try {
|
||||||
|
sb.append(k).append('=').append(URLEncoder.encode(v, "UTF-8"));
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有参数名
|
* 获取所有参数名
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user