public class WebController extends Object implements Controller
| 构造器和说明 |
|---|
WebController() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected WebController |
addHeader(String key,
String value)
设置
HttpServletResponseHeader属性 |
AppContext |
getAppContext() |
protected <T> T |
getAttr(String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
|
protected Enumeration<String> |
getAttrNames()
Returns an Enumeration containing the names of the attributes available to this request.
|
protected String |
getCookie(String name)
Get cookie value by cookie name.
|
protected String |
getCookie(String name,
String defaultValue)
Get cookie value by cookie name.
|
protected javax.servlet.http.Cookie |
getCookieObject(String name)
Get cookie object by cookie name.
|
protected javax.servlet.http.Cookie[] |
getCookieObjects() |
protected Integer |
getCookieToInt(String name)
Get cookie value by cookie name and convert to Integer.
|
protected Integer |
getCookieToInt(String name,
Integer defaultValue)
Get cookie value by cookie name and convert to Integer.
|
protected Long |
getCookieToLong(String name)
Get cookie value by cookie name and convert to Long.
|
protected Long |
getCookieToLong(String name,
Long defaultValue)
Get cookie value by cookie name and convert to Long.
|
protected <T> T |
getData(String name)
返回 Invoker 保存的数据。
|
protected Set<String> |
getDataNames()
返回 Invoker 保存的数据keys。
|
protected <T> T |
getInstance(Class<T> modelClass) |
protected <T> T |
getInstance(Class<T> modelClass,
String modelName) |
protected Object |
getInstance(String bindID) |
protected Invoker |
getInvoker() |
protected List<FileItem> |
getMultipart(String parameterName)
将 Multipart 请求数据缓存到一个目录下,同时返回 FileItem 列表。
|
protected List<FileItem> |
getMultipart(String parameterName,
Integer maxPostSize)
将 Multipart 请求数据缓存到一个目录下,同时返回 FileItem 列表,
|
protected List<FileItem> |
getMultipart(String parameterName,
String cacheDirectory,
Integer maxPostSize)
将 Multipart 请求数据缓存到一个目录下,同时返回 FileItem 列表.
|
protected List<FileItem> |
getMultipart(String parameterName,
String cacheDirectory,
Integer maxPostSize,
String encoding)
将 Multipart 请求数据缓存到一个目录下,同时返回 FileItem 列表。
|
protected Iterator<FileItemStream> |
getMultipartIterator()
返回流式处理文件上传的迭代器。
|
protected Iterator<FileItemStream> |
getMultipartIterator(Integer maxPostSize)
返回流式处理文件上传的迭代器。
|
protected Iterator<FileItemStream> |
getMultipartIterator(Integer maxPostSize,
String encoding)
返回流式处理文件上传的迭代器。
|
protected List<FileItem> |
getMultipartList()
将 multipart 请求数据缓存到一个目录下,同时返回 FileItem 列表.
|
protected List<FileItem> |
getMultipartList(FileItemFactory factory)
将 Multipart 请求数据缓存到一个目录下,同时返回 FileItem 列表。
|
protected List<FileItem> |
getMultipartList(FileItemFactory factory,
Integer maxPostSize)
将 Multipart 请求数据缓存到一个目录下,同时返回 FileItem 列表。
|
protected List<FileItem> |
getMultipartList(FileItemFactory factory,
Integer maxPostSize,
String encoding)
将 Multipart 请求数据缓存到一个目录下,同时返回 FileItem 列表。
|
protected List<FileItem> |
getMultipartList(Integer maxPostSize)
将 Multipart 请求数据缓存到一个目录下,同时返回 FileItem 列表.
|
protected List<FileItem> |
getMultipartList(String cacheDirectory,
Integer maxPostSize)
将 Multipart 请求数据缓存到一个目录下,同时返回 FileItem 列表.
|
protected List<FileItem> |
getMultipartList(String cacheDirectory,
Integer maxPostSize,
String encoding)
将 Multipart 请求数据缓存到一个目录下,同时返回 FileItem 列表。
|
protected String |
getPara(String name)
Returns the value of a request parameter as a String, or null if the parameter does not exist.
|
protected String |
getPara(String name,
String defaultValue)
Returns the value of a request parameter as a String, or default value if the parameter does not exist.
|
protected Map<String,String[]> |
getParaMap()
Returns the values of the request parameters as a Map.
|
protected Enumeration<String> |
getParaNames()
Returns an Enumeration of String objects containing the names of the parameters contained in this request.
|
protected Boolean |
getParaToBoolean(String name)
Returns the value of a request parameter and convert to Boolean.
|
protected Boolean |
getParaToBoolean(String name,
Boolean defaultValue)
Returns the value of a request parameter and convert to Boolean with a default value if it is null.
|
protected Integer |
getParaToInt(String name)
Returns the value of a request parameter and convert to Integer.
|
protected Integer |
getParaToInt(String name,
Integer defaultValue)
Returns the value of a request parameter and convert to Integer with a default value if it is null.
|
protected Long |
getParaToLong(String name)
Returns the value of a request parameter and convert to Long.
|
protected Long |
getParaToLong(String name,
Long defaultValue)
Returns the value of a request parameter and convert to Long with a default value if it is null.
|
protected String[] |
getParaValues(String name)
Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
|
protected Integer[] |
getParaValuesToInt(String name)
Returns an array of Integer objects containing all of the values the given request parameter has, or null if the parameter does not exist.
|
javax.servlet.http.HttpServletRequest |
getRequest() |
javax.servlet.http.HttpServletResponse |
getResponse() |
protected javax.servlet.http.HttpSession |
getSession() |
protected javax.servlet.http.HttpSession |
getSession(boolean create)
Return HttpSession.
|
protected <T> T |
getSessionAttr(String key)
Return a Object from session.
|
void |
initController(Invoker renderData)
在处理新请求之前,初始化这个控制器。
|
protected boolean |
isMultipart()
返回为 Multipart 请求,通常 Multipart 请求都包含一个或多个的文件上传。
|
protected FileUpload |
newFileUpload(Integer maxPostSize,
String encoding)
创建原始的FileUpload对象。
|
protected WebController |
putData(String name,
Object value)
设置 Invoker 保存的数据。
|
protected WebController |
removeAttr(String name)
Removes an attribute from this request
|
protected WebController |
removeCookie(String name)
Remove Cookie with path = "/".
|
protected WebController |
removeCookie(String name,
String path)
Remove Cookie.
|
protected WebController |
removeCookie(String name,
String path,
String domain)
Remove Cookie.
|
protected WebController |
removeData(String name)
删除 Invoker 保存的数据。
|
protected WebController |
removeSessionAttr(String key)
Remove Object in session.
|
protected void |
renderTo(String viewName)
更新渲染模版。
|
protected void |
renderTo(String renderType,
String viewName)
更新渲染模版。
|
protected WebController |
setAttr(String name,
Object value)
Stores an attribute in this request
|
protected WebController |
setAttrs(Map<String,Object> attrMap)
Stores attributes in this request, key of the map as attribute name and value of the map as attribute value
|
protected WebController |
setCookie(javax.servlet.http.Cookie cookie)
Set Cookie to response.
|
protected WebController |
setCookie(String name,
String value,
int maxAgeInSeconds)
Set Cookie with path = "/".
|
protected WebController |
setCookie(String name,
String value,
int maxAgeInSeconds,
String path)
Set Cookie to response.
|
protected WebController |
setCookie(String name,
String value,
int maxAgeInSeconds,
String path,
String domain)
Set Cookie to response.
|
protected WebController |
setDatas(Map<String,Object> attrMap)
设置 Invoker 保存的数据。
|
protected WebController |
setHeader(String key,
String value)
设置
HttpServletResponseHeader属性 |
protected WebController |
setSessionAttr(String key,
Object value)
Store Object to session.
|
public void initController(Invoker renderData)
ControllerinitController 在接口中 Controllerprotected Invoker getInvoker()
public javax.servlet.http.HttpServletRequest getRequest()
public javax.servlet.http.HttpServletResponse getResponse()
public AppContext getAppContext()
protected WebController setHeader(String key, String value)
HttpServletResponseHeader属性key - 参数 keyvalue - 参数值protected WebController addHeader(String key, String value)
HttpServletResponseHeader属性key - 参数 keyvalue - 参数值protected String getPara(String name)
You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use getParaValues(java.lang.String).
If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by getParameterValues.
name - a String specifying the name of the parameterprotected String getPara(String name, String defaultValue)
name - a String specifying the name of the parameterdefaultValue - a String value be returned when the value of parameter is nullprotected Map<String,String[]> getParaMap()
protected Enumeration<String> getParaNames()
protected String[] getParaValues(String name)
name - a String containing the name of the parameter whose value is requestedprotected Integer[] getParaValuesToInt(String name)
name - a String containing the name of the parameter whose value is requestedprotected Integer getParaToInt(String name)
name - a String specifying the name of the parameterprotected Integer getParaToInt(String name, Integer defaultValue)
name - a String specifying the name of the parameterdefaultValue - default value for the parameterprotected Long getParaToLong(String name)
name - a String specifying the name of the parameterprotected Long getParaToLong(String name, Long defaultValue)
name - a String specifying the name of the parameterdefaultValue - default value for the parameterprotected Boolean getParaToBoolean(String name)
name - a String specifying the name of the parameterprotected Boolean getParaToBoolean(String name, Boolean defaultValue)
name - a String specifying the name of the parameterdefaultValue - default value for the parameterprotected javax.servlet.http.HttpSession getSession()
protected javax.servlet.http.HttpSession getSession(boolean create)
create - a boolean specifying create HttpSession if it not existsprotected <T> T getSessionAttr(String key)
key - a String specifying the key of the Object stored in sessionprotected WebController setSessionAttr(String key, Object value)
key - a String specifying the key of the Object stored in sessionvalue - a Object specifying the value stored in sessionprotected WebController removeSessionAttr(String key)
key - a String specifying the key of the Object stored in sessionprotected String getCookie(String name, String defaultValue)
name - cookie namedefaultValue - default valueprotected String getCookie(String name)
name - cookie nameprotected Integer getCookieToInt(String name)
name - cookie nameprotected Integer getCookieToInt(String name, Integer defaultValue)
name - cookie namedefaultValue - default valueprotected Long getCookieToLong(String name)
name - cookie nameprotected Long getCookieToLong(String name, Long defaultValue)
name - cookie namedefaultValue - default valueprotected javax.servlet.http.Cookie getCookieObject(String name)
name - cookie nameprotected javax.servlet.http.Cookie[] getCookieObjects()
protected WebController setCookie(javax.servlet.http.Cookie cookie)
cookie - new cookie.protected WebController setCookie(String name, String value, int maxAgeInSeconds, String path)
name - cookie namevalue - cookie valuemaxAgeInSeconds - -1: clear cookie when close browser. 0: clear cookie immediately. n > 0 : max age in n seconds.path - see Cookie.setPath(String)protected WebController setCookie(String name, String value, int maxAgeInSeconds, String path, String domain)
name - cookie namevalue - cookie valuemaxAgeInSeconds - -1: clear cookie when close browser. 0: clear cookie immediately. n > 0 : max age in n seconds.path - see Cookie.setPath(String)domain - the domain name within which this cookie is visible; form is according to RFC 2109protected WebController setCookie(String name, String value, int maxAgeInSeconds)
name - cookie namevalue - cookie valuemaxAgeInSeconds - max ageprotected WebController removeCookie(String name)
name - cookie nameprotected WebController removeCookie(String name, String path)
name - cookie namepath - cookie with path = "/".protected WebController removeCookie(String name, String path, String domain)
name - cookie namepath - cookie with path = "/".domain - domainprotected <T> T getAttr(String name)
name - a String specifying the name of the attributeprotected WebController setAttr(String name, Object value)
name - a String specifying the name of the attributevalue - the Object to be storedprotected WebController removeAttr(String name)
name - a String specifying the name of the attribute to removeprotected WebController setAttrs(Map<String,Object> attrMap)
attrMap - key and value as attribute of the map to be storedprotected Enumeration<String> getAttrNames()
protected <T> T getData(String name)
protected WebController putData(String name, Object value)
protected WebController removeData(String name)
protected WebController setDatas(Map<String,Object> attrMap)
protected <T> T getInstance(Class<T> modelClass, String modelName)
protected <T> T getInstance(Class<T> modelClass)
protected void renderTo(String viewName)
protected void renderTo(String renderType, String viewName)
renderType - 如果注释了 Produces注解那么该参数将会失效。viewName - 模版名称protected boolean isMultipart()
FileUpload.isMultipartContent(HttpServletRequest)protected List<FileItem> getMultipartList() throws IOException
IOExceptionprotected List<FileItem> getMultipartList(Integer maxPostSize) throws IOException
maxPostSize - 最大单个 body 大小IOExceptionprotected List<FileItem> getMultipartList(String cacheDirectory, Integer maxPostSize) throws IOException
cacheDirectory - 缓存目录maxPostSize - 最大单个 body 大小IOExceptionprotected List<FileItem> getMultipartList(String cacheDirectory, Integer maxPostSize, String encoding) throws IOException
cacheDirectory - 缓存目录(默认配置位于:"hasor.fileupload.cacheDirectory")maxPostSize - 最大单个 body 大小encoding - 字符编码。IOExceptionprotected List<FileItem> getMultipartList(FileItemFactory factory) throws IOException
factory - 缓存策略IOExceptionprotected List<FileItem> getMultipartList(FileItemFactory factory, Integer maxPostSize) throws IOException
factory - 缓存策略maxPostSize - 最大单个 body 大小IOExceptionprotected List<FileItem> getMultipartList(FileItemFactory factory, Integer maxPostSize, String encoding) throws IOException
factory - 缓存策略maxPostSize - 最大单个 body 大小encoding - 字符编码。IOExceptionprotected List<FileItem> getMultipart(String parameterName) throws IOException
parameterName - 要获取的制定参数表单名IOExceptionprotected List<FileItem> getMultipart(String parameterName, Integer maxPostSize) throws IOException
parameterName - 要获取的制定参数表单名maxPostSize - 最大单个 body 大小IOExceptionprotected List<FileItem> getMultipart(String parameterName, String cacheDirectory, Integer maxPostSize) throws IOException
parameterName - 要获取的制定参数表单名cacheDirectory - 缓存目录maxPostSize - 最大单个 body 大小IOExceptionprotected List<FileItem> getMultipart(String parameterName, String cacheDirectory, Integer maxPostSize, String encoding) throws IOException
parameterName - 要获取的制定参数表单名cacheDirectory - 缓存目录maxPostSize - 最大单个 body 大小encoding - 字符编码。IOExceptionprotected Iterator<FileItemStream> getMultipartIterator() throws IOException
IOExceptionprotected Iterator<FileItemStream> getMultipartIterator(Integer maxPostSize) throws IOException
maxPostSize - 最大单个 body 大小IOExceptionprotected Iterator<FileItemStream> getMultipartIterator(Integer maxPostSize, String encoding) throws IOException
maxPostSize - 最大单个 body 大小encoding - 字符编码。IOExceptionprotected FileUpload newFileUpload(Integer maxPostSize, String encoding)
maxPostSize - 最大单个 body 大小encoding - 字符编码。Copyright © 2020. All rights reserved.