public class NetworkHelper
extends java.lang.Object
构造器和说明 |
---|
NetworkHelper() |
限定符和类型 | 方法和说明 |
---|---|
static java.io.PrintWriter |
createPrintWriter(javax.servlet.http.HttpServletResponse res)
生成一个打印输出器
|
static java.io.PrintWriter |
createPrintWriter(javax.servlet.http.HttpServletResponse res,
java.lang.String charsetName)
按指定编码生成打印输出器
|
static java.lang.String |
createServletURL(javax.servlet.http.HttpServletRequest req)
生成一个访问Servelt的相对路径
|
static java.lang.String |
createServletURL(javax.servlet.http.HttpServletRequest req,
java.lang.String servletName)
生成一个访问Servelt的相对路径
|
static Device |
getDevice(javax.servlet.http.HttpServletRequest req)
根据网络请求判定发起请求的设备
|
static boolean |
getHTTPRequestBoolParameter(javax.servlet.http.HttpServletRequest req,
java.lang.String paraName)
把HTTP请求中指定名字的参数值转化为布尔值
|
static java.lang.String |
getHTTPRequestEncodeParameter(javax.servlet.http.HttpServletRequest req,
java.lang.String paraName,
boolean encode)
获取HTTP请求中指定名字的参数值
|
static java.lang.String |
getHTTPRequestFileNameParameter(javax.servlet.http.HttpServletRequest req)
获取文件名
|
static int |
getHTTPRequestIntParameter(javax.servlet.http.HttpServletRequest req,
java.lang.String paraName)
把HTTP请求中指定名字的参数值转化为整数,参数为空或不是整数则返回-1
|
static int |
getHTTPRequestIntParameter(javax.servlet.http.HttpServletRequest req,
java.lang.String paraName,
int defaultValue)
把HTTP请求中指定名字的参数值转化为整数
|
static java.lang.String |
getHTTPRequestParameter(javax.servlet.http.HttpServletRequest req,
java.lang.String... paraNames)
获取第一个不为空的参数
|
static java.lang.String |
getHTTPRequestParameter(javax.servlet.http.HttpServletRequest req,
java.lang.String paraName)
获取HTTP请求中指定名字的参数值
|
static java.lang.String |
getHTTPRequestSessionIDParameter(javax.servlet.http.HttpServletRequest req)
获取sessionID
|
static java.lang.String |
getOriginalURL(javax.servlet.http.HttpServletRequest req)
返回发起指定HTTP请求的URL地址
|
static java.lang.String |
getOriginalURL(javax.servlet.http.HttpServletRequest req,
boolean decodeQueryString)
返回发起指定HTTP请求的URL地址
|
static java.io.InputStream |
getRequestInputStream(javax.servlet.http.HttpServletRequest req)
获取req中的inpustream
|
static Format |
getResponseContentFormat(javax.servlet.http.HttpServletRequest req) |
static void |
setCacheSettings(javax.servlet.http.HttpServletResponse res)
清楚缓存设置
|
static void |
writeOutTemplate(java.lang.String resource,
javax.servlet.http.HttpServletResponse response,
java.util.Map map)
写出指定的模板
|
public static java.lang.String createServletURL(javax.servlet.http.HttpServletRequest req)
req
- HTTP请求public static java.lang.String createServletURL(javax.servlet.http.HttpServletRequest req, java.lang.String servletName)
req
- HTTP请求public static java.io.InputStream getRequestInputStream(javax.servlet.http.HttpServletRequest req)
req
- HTTP请求public static java.lang.String getHTTPRequestParameter(javax.servlet.http.HttpServletRequest req, java.lang.String paraName)
req
- HTTP请求paraName
- 参数名public static java.lang.String getHTTPRequestParameter(javax.servlet.http.HttpServletRequest req, java.lang.String... paraNames)
req
- HTTP请求paraNames
- 参数列表public static boolean getHTTPRequestBoolParameter(javax.servlet.http.HttpServletRequest req, java.lang.String paraName)
req
- HTTP请求paraName
- 参数名public static int getHTTPRequestIntParameter(javax.servlet.http.HttpServletRequest req, java.lang.String paraName)
req
- HTTP请求paraName
- 参数名public static int getHTTPRequestIntParameter(javax.servlet.http.HttpServletRequest req, java.lang.String paraName, int defaultValue)
req
- HTTP请求paraName
- 参数名defaultValue
- 默认值public static java.lang.String getHTTPRequestSessionIDParameter(javax.servlet.http.HttpServletRequest req)
req
- HTTP请求public static java.lang.String getHTTPRequestFileNameParameter(javax.servlet.http.HttpServletRequest req)
req
- HTTP请求public static java.lang.String getHTTPRequestEncodeParameter(javax.servlet.http.HttpServletRequest req, java.lang.String paraName, boolean encode)
req
- paraName
- encode
- public static java.lang.String getOriginalURL(javax.servlet.http.HttpServletRequest req)
req
- HTTP请求public static java.lang.String getOriginalURL(javax.servlet.http.HttpServletRequest req, boolean decodeQueryString)
req
- req HTTP请求decodeQueryString
- 是否解码参数queryStringpublic static void writeOutTemplate(java.lang.String resource, javax.servlet.http.HttpServletResponse response, java.util.Map map) throws java.io.IOException
resource
- 模板路径response
- HTTP响应map
- 用于替换模板中参数的的参数集java.io.IOException
public static java.io.PrintWriter createPrintWriter(javax.servlet.http.HttpServletResponse res) throws java.io.IOException
res
- HTTP响应java.io.IOException
public static java.io.PrintWriter createPrintWriter(javax.servlet.http.HttpServletResponse res, java.lang.String charsetName) throws java.io.IOException
res
- HTTP响应charsetName
- 编码java.io.IOException
public static void setCacheSettings(javax.servlet.http.HttpServletResponse res)
res
- HTTP响应public static Device getDevice(javax.servlet.http.HttpServletRequest req)
req
- HTTP请求public static Format getResponseContentFormat(javax.servlet.http.HttpServletRequest req)