public interface Response
限定符和类型 | 方法和说明 |
---|---|
default Response |
badRequest()
Set current response http code 400
|
default void |
body(byte[] data)
Send response body by byte array.
|
default void |
body(io.netty.buffer.ByteBuf byteBuf)
Send response body by ByteBuf.
|
default void |
body(String data)
send body to client
|
String |
contentType()
Get current response headers: contentType
|
Response |
contentType(CharSequence contentType)
Setting Response ContentType
|
Response |
cookie(Cookie cookie)
add raw response cookie
|
Response |
cookie(String name,
String value)
add Cookie
|
Response |
cookie(String name,
String value,
int maxAge)
Setting Cookie
|
Response |
cookie(String name,
String value,
int maxAge,
boolean secured)
Setting Cookie
|
Response |
cookie(String path,
String name,
String value,
int maxAge,
boolean secured)
Setting Cookie
|
Map<String,String> |
cookies()
Get current response cookies
|
void |
download(String fileName,
File file)
download some file to client
|
Response |
header(CharSequence name,
CharSequence value)
Set current response header
|
Map<String,String> |
headers()
Get current response headers
|
default void |
html(String html)
Render by html
|
boolean |
isCommit()
Judge whether the current response has been submitted to the client
|
default void |
json(Object bean)
Render by json
|
default void |
json(String json)
Render by json
|
default Response |
notFound()
Set current response http code 404
|
OutputStreamWrapper |
outputStream()
create temp file outputStream
|
void |
redirect(String newUri)
Redirect to newUri
|
Response |
removeCookie(String name)
remove cookie
|
void |
render(ModelAndView modelAndView)
Render view And Setting Data
|
default void |
render(String view)
Render view
|
void |
send(io.netty.handler.codec.http.FullHttpResponse response)
Send response by FullHttpResponse, custom build, please be careful
|
Response |
status(int status)
Setting Response Status
|
int |
statusCode()
Get current response http status code. e.g: 200
|
default void |
text(String text)
Render by text
|
default Response |
unauthorized()
Set current response http code 401
|
int statusCode()
Response status(int status)
status
- status codedefault Response badRequest()
default Response unauthorized()
default Response notFound()
Response contentType(CharSequence contentType)
contentType
- content typeString contentType()
Response header(CharSequence name, CharSequence value)
name
- Header Namevalue
- Header ValueResponse cookie(Cookie cookie)
cookie
- Response cookie(String name, String value)
name
- Cookie Namevalue
- Cookie ValueResponse cookie(String name, String value, int maxAge)
name
- Cookie Namevalue
- Cookie ValuemaxAge
- Period of validityResponse cookie(String name, String value, int maxAge, boolean secured)
name
- Cookie Namevalue
- Cookie ValuemaxAge
- Period of validitysecured
- Is SSLResponse cookie(String path, String name, String value, int maxAge, boolean secured)
path
- Cookie Domain Pathname
- Cookie Namevalue
- Cookie ValuemaxAge
- Period of validitysecured
- Is SSLResponse removeCookie(String name)
name
- default void text(String text)
text
- text contentdefault void html(String html)
html
- html contentdefault void json(String json)
json
- json contentdefault void json(Object bean)
bean
- bean instancedefault void body(String data)
data
- body stringdefault void body(byte[] data)
data
- byte array datadefault void body(io.netty.buffer.ByteBuf byteBuf)
byteBuf
- ByteBuf datavoid download(String fileName, File file) throws Exception
fileName
- give client file namefile
- file storage locationException
OutputStreamWrapper outputStream() throws IOException
IOException
- throw IOExceptiondefault void render(String view)
view
- view pagevoid render(ModelAndView modelAndView)
modelAndView
- ModelAndView objectvoid redirect(String newUri)
newUri
- new urlboolean isCommit()
void send(io.netty.handler.codec.http.FullHttpResponse response)
response
- FullHttpResponse instanceCopyright © 2017. All rights reserved.