public abstract class Context extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected Charset |
charset |
Throwable |
errors
用于在处理链中透传处理错误
|
Object |
result
用于在处理链中透传处理结果
|
protected SessionState |
sessionState |
| 构造器和说明 |
|---|
Context() |
| 限定符和类型 | 方法和说明 |
|---|---|
String |
accept()
获取 Accept 头信息
|
Action |
action()
获取当前动作
|
<T> T |
attr(String name)
获取上下文特性
|
<T> T |
attr(String name,
T def)
获取上下文特性
|
void |
attrClear()
清除上下文特性
|
Map<String,Object> |
attrMap() |
void |
attrSet(Map<String,Object> map)
设置上下文特性
|
void |
attrSet(String name,
Object val)
设置上下文特性
|
boolean |
autoMultipart()
是否自动解析分段内容
|
void |
autoMultipart(boolean auto)
设置是否自动解析分段内容
|
String |
body()
获取body内容
|
String |
body(String charset)
获取body内容
|
byte[] |
bodyAsBytes()
获取body内容为byte[]
|
abstract InputStream |
bodyAsStream()
获取body内容为Stream
|
String |
bodyNew()
获取新的body
|
void |
bodyNew(String bodyNew)
设置新的body
|
void |
charset(String charset)
设置字符集
|
void |
close() |
protected void |
commit() |
abstract long |
contentLength()
获取内容长度
|
abstract String |
contentType()
获取内容类型
|
void |
contentType(String contentType)
设置内容类型
|
protected abstract void |
contentTypeDoSet(String contentType) |
String |
contentTypeNew()
获取设置的新内容类型
|
Object |
controller()
获取当前控制器
|
String |
cookie(String name)
获取 cookie
|
String |
cookie(String name,
String def)
获取 cookie
|
abstract NvMap |
cookieMap()
获取 cookieMap
|
void |
cookieRemove(String name)
移徐 cookie
|
void |
cookieSet(String name,
String val)
设置 cookie
|
void |
cookieSet(String name,
String val,
int maxAge)
设置 cookie
|
void |
cookieSet(String name,
String val,
String domain,
int maxAge)
设置 cookie
|
abstract void |
cookieSet(String name,
String val,
String domain,
String path,
int maxAge)
设置 cookie
|
static Context |
current()
获取当前线程的上下文
|
UploadedFile |
file(String name)
获取上传文件
|
abstract List<UploadedFile> |
files(String name)
获取上传文件
|
abstract void |
flush() |
void |
forward(String pathNew) |
boolean |
getHandled()
获取处理状态
|
Locale |
getLocale()
获取地区
|
boolean |
getRendered()
获取渲染状态
|
String |
header(String name)
获取 header
|
String |
header(String name,
String def)
获取 header
|
abstract void |
headerAdd(String name,
String val)
添加 header
|
abstract NvMap |
headerMap()
获取 headerMap
|
abstract void |
headerSet(String name,
String val)
设置 header
|
abstract String |
ip()
获取远程IP
|
boolean |
isMultipart()
是否为分段内容
|
boolean |
isMultipartFormData()
是否为分段表单数据
|
abstract String |
method()
获取请求方法
|
abstract void |
output(byte[] bytes)
输出 字节数组
|
abstract void |
output(InputStream stream)
输出 流对象
|
void |
output(String str)
输出 字符串
|
void |
output(Throwable ex)
输出 异常对象
|
void |
outputAsFile(DownloadedFile file)
输出为文件
|
void |
outputAsFile(File file)
输出为文件
|
void |
outputAsHtml(String html)
输出为html文本
|
void |
outputAsJson(String json)
输出为json文本
|
abstract OutputStream |
outputStream()
获取输出流
|
abstract String |
param(String name)
获取参数
|
abstract String |
param(String name,
String def)
获取参数
|
<T> T |
paramAsBean(Class<T> type)
获取参数并转为Bean
|
BigDecimal |
paramAsDecimal(String name)
获取参数并转为BigDecimal
|
BigDecimal |
paramAsDecimal(String name,
BigDecimal def)
获取参数并转为BigDecimal
|
double |
paramAsDouble(String name)
获取参数并转为double
|
double |
paramAsDouble(String name,
double def)
获取参数并转为double
|
int |
paramAsInt(String name)
获取参数并转为int
|
int |
paramAsInt(String name,
int def)
获取参数并转为int
|
long |
paramAsLong(String name)
获取参数并转为long
|
long |
paramAsLong(String name,
long def)
获取参数并转为long
|
abstract NvMap |
paramMap()
获取所有参数并转为map
|
void |
paramsAdd(String name,
String val)
添加参数
|
void |
paramSet(String name,
String val)
设置参数
|
abstract Map<String,List<String>> |
paramsMap()
获取所有参数并转为Map
|
abstract String[] |
paramValues(String name)
获取参数数组
|
String |
path() |
String |
pathAsUpper()
获取请求的URI路径并大写
|
NvMap |
pathMap(String expr)
获取请求的URI路径变量,根据路径表达式
|
String |
pathNew()
获取新路径,不存在则返回原路径
|
void |
pathNew(String pathNew)
设置新路径
|
abstract String |
protocol()
获取请求协议
|
String |
protocolAsUpper()
获取请求协议并大写
|
abstract String |
queryString()
获取查询字符串
|
String |
realIp()
获取客户端真实IP
|
abstract void |
redirect(String url)
跳转地址
|
abstract void |
redirect(String url,
int code) |
boolean |
remoting()
是否为远程调用
|
void |
remotingSet(boolean remoting) |
void |
render(Object obj)
渲染数据(不能重写,避免死循环)
|
void |
render(String view,
Map<String,?> data)
渲染数据
|
String |
renderAndReturn(Object obj)
渲染数据并返回
|
abstract Object |
request()
获取请求对象
|
abstract Object |
response()
获取响应对象
|
Object |
session(String name)
获取 session 状态
|
<T> T |
session(String name,
T def)
获取 session 状态(类型转换,存在风险)
|
double |
sessionAsDouble(String name)
获取 session 状态,并以 double 型输出
|
double |
sessionAsDouble(String name,
double def)
获取 session 状态,并以 double 型输出
|
int |
sessionAsInt(String name)
获取 session 状态,并以 int 型输出
|
int |
sessionAsInt(String name,
int def)
获取 session 状态,并以 int 型输出
|
long |
sessionAsLong(String name)
获取 session 状态,并以 long 型输出
|
long |
sessionAsLong(String name,
long def)
获取 session 状态,并以 long 型输出
|
void |
sessionClear()
清空 session 状态
|
String |
sessionId()
获取 sessionId
|
void |
sessionRemove(String name)
移除 session 状态
|
void |
sessionSet(String name,
Object val)
设置 session 状态
|
SessionState |
sessionState()
获取 sessionState
|
void |
setHandled(boolean handled)
设置处理状态
|
void |
setLocale(Locale locale)
设置地区
|
void |
setRendered(boolean rendered)
设置渲染状态
|
abstract int |
status()
获取输出状态
|
void |
status(int status)
设置输出状态
|
protected abstract void |
statusDoSet(int status) |
void |
statusSet(int status)
已过时。
|
abstract URI |
uri()
获取请求的URI
|
abstract String |
url()
获取请求的URL字符串
|
String |
userAgent()
获取请求的UA
|
protected SessionState sessionState
protected Charset charset
public static Context current()
public Locale getLocale()
public void setLocale(Locale locale)
@Note(value="\u8bbe\u7f6e\u5904\u7406\u72b6\u6001") public void setHandled(boolean handled)
@Note(value="\u8bbe\u7f6e\u6e32\u67d3\u72b6\u6001") public void setRendered(boolean rendered)
public boolean autoMultipart()
public void autoMultipart(boolean auto)
public boolean isMultipart()
public boolean isMultipartFormData()
@Note(value="\u83b7\u53d6\u8bf7\u6c42\u534f\u8bae") public abstract String protocol()
public String protocolAsUpper()
public abstract URI uri()
public String path()
public void pathNew(String pathNew)
public String pathNew()
public String pathAsUpper()
public String userAgent()
public abstract String url()
public abstract long contentLength()
public abstract String contentType()
public abstract String queryString()
public String accept()
public String body() throws IOException
IOExceptionpublic String body(String charset) throws IOException
IOExceptionpublic String bodyNew() throws IOException
IOExceptionpublic void bodyNew(String bodyNew)
public byte[] bodyAsBytes()
throws IOException
IOExceptionpublic abstract InputStream bodyAsStream() throws IOException
IOExceptionpublic int paramAsInt(String name)
public int paramAsInt(String name, int def)
public long paramAsLong(String name)
public long paramAsLong(String name, long def)
public double paramAsDouble(String name)
public double paramAsDouble(String name, double def)
public BigDecimal paramAsDecimal(String name)
public BigDecimal paramAsDecimal(String name, BigDecimal def)
public <T> T paramAsBean(Class<T> type)
public abstract NvMap paramMap()
public abstract List<UploadedFile> files(String name) throws Exception
name - 文件名Exceptionpublic UploadedFile file(String name) throws Exception
name - 文件名Exceptionpublic abstract NvMap cookieMap()
public abstract NvMap headerMap()
public SessionState sessionState()
public final String sessionId()
@Note(value="\u6cdb\u578b\u8f6c\u6362\uff0c\u5b58\u5728\u8f6c\u6362\u98ce\u9669") public final <T> T session(String name, T def)
name - 状态名public final int sessionAsInt(String name)
name - 状态名public final int sessionAsInt(String name, int def)
name - 状态名public final long sessionAsLong(String name)
name - 状态名public final long sessionAsLong(String name, long def)
name - 状态名public final double sessionAsDouble(String name)
name - 状态名public final double sessionAsDouble(String name, double def)
name - 状态名public final void sessionSet(String name, Object val)
name - 状态名val - 值public final void sessionRemove(String name)
name - 状态名public final void sessionClear()
public abstract Object response()
public void charset(String charset)
public void contentType(String contentType)
public String contentTypeNew()
protected abstract void contentTypeDoSet(String contentType)
public abstract void output(byte[] bytes)
public abstract void output(InputStream stream)
public abstract OutputStream outputStream() throws IOException
IOExceptionpublic void output(String str)
public void output(Throwable ex)
public void outputAsJson(String json)
public void outputAsHtml(String html)
public void outputAsFile(DownloadedFile file) throws IOException
IOExceptionpublic void outputAsFile(File file) throws IOException
IOExceptionpublic abstract void cookieSet(String name, String val, String domain, String path, int maxAge)
public void cookieRemove(String name)
@Note(value="\u8df3\u8f6c\u5730\u5740") public abstract void redirect(String url, int code)
@Deprecated public void statusSet(int status)
protected abstract void statusDoSet(int status)
@Note(value="\u83b7\u53d6\u81ea\u5b9a\u4e49\u7279\u6027\u5e76\u8f6c\u4e3aMap") public Map<String,Object> attrMap()
public <T> T attr(String name, T def)
public <T> T attr(String name)
public void attrClear()
public final void render(String view, Map<String,?> data) throws Throwable
Throwablepublic final String renderAndReturn(Object obj) throws Throwable
Throwable@Note(value="\u662f\u5426\u4e3a\u8fdc\u7a0b\u8c03\u7528") public boolean remoting()
public void remotingSet(boolean remoting)
@Note(value="\u51b2\u5237") public abstract void flush() throws IOException
IOException@Note(value="\u63d0\u4ea4\u54cd\u5e94") protected void commit() throws IOException
IOException@Note(value="\u5173\u95ed\u54cd\u5e94") public void close() throws IOException
IOExceptionCopyright © 2022. All rights reserved.