public abstract class Controller extends Object
| 构造器和说明 |
|---|
Controller() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
checkUrlPara(int length) |
void |
checkUrlPara(int minLength,
int maxLength) |
void |
createToken()
Create a token with default token name and with default seconds of time out.
|
void |
createToken(String tokenName)
Create a token with default seconds of time out.
|
void |
createToken(String tokenName,
int secondsOfTimeOut)
Create a token.
|
<T> T |
enhance(Class<T> targetClass) |
<T> T |
enhance(Class<T> targetClass,
Class<? extends Interceptor>... injectIntersClasses) |
<T> T |
enhance(Class<T> targetClass,
Class<? extends Interceptor> injectIntersClass) |
<T> T |
enhance(Class<T> targetClass,
Class<? extends Interceptor> injectIntersClass1,
Class<? extends Interceptor> injectIntersClass2) |
<T> T |
enhance(Class<T> targetClass,
Class<? extends Interceptor> injectIntersClass1,
Class<? extends Interceptor> injectIntersClass2,
Class<? extends Interceptor> injectIntersClass3) |
<T> T |
enhance(Class<T> targetClass,
Interceptor... injectInters) |
<T> T |
enhance(Object target) |
<T> T |
enhance(Object target,
Class<? extends Interceptor>... injectIntersClasses) |
<T> T |
enhance(Object target,
Class<? extends Interceptor> injectIntersClass) |
<T> T |
enhance(Object target,
Class<? extends Interceptor> injectIntersClass1,
Class<? extends Interceptor> injectIntersClass2) |
<T> T |
enhance(Object target,
Class<? extends Interceptor> injectIntersClass1,
Class<? extends Interceptor> injectIntersClass2,
Class<? extends Interceptor> injectIntersClass3) |
<T> T |
enhance(Object target,
Interceptor... injectInters) |
<T> T |
enhance(String singletonKey,
Class<T> targetClass) |
<T> T |
enhance(String singletonKey,
Class<T> targetClass,
Class<? extends Interceptor>... injectIntersClasses) |
<T> T |
enhance(String singletonKey,
Class<T> targetClass,
Interceptor... injectInters) |
<T> T |
enhance(String singletonKey,
Object target) |
<T> T |
enhance(String singletonKey,
Object target,
Class<? extends Interceptor>... injectIntersClasses) |
<T> T |
enhance(String singletonKey,
Object target,
Interceptor... injectInters) |
void |
forwardAction(String actionUrl)
Forward to an action
|
<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.
|
Integer |
getAttrForInt(String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given
name exists.
|
String |
getAttrForStr(String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given
name exists.
|
Enumeration<String> |
getAttrNames()
Returns an Enumeration containing the names of the attributes available to this request.
|
String |
getCookie(String name)
Get cookie value by cookie name.
|
String |
getCookie(String name,
String defaultValue)
Get cookie value by cookie name.
|
javax.servlet.http.Cookie |
getCookieObject(String name)
Get cookie object by cookie name.
|
javax.servlet.http.Cookie[] |
getCookieObjects()
Get all cookie objects.
|
Integer |
getCookieToInt(String name)
Get cookie value by cookie name and convert to Integer.
|
Integer |
getCookieToInt(String name,
Integer defaultValue)
Get cookie value by cookie name and convert to Integer.
|
Long |
getCookieToLong(String name)
Get cookie value by cookie name and convert to Long.
|
Long |
getCookieToLong(String name,
Long defaultValue)
Get cookie value by cookie name and convert to Long.
|
UploadFile |
getFile() |
UploadFile |
getFile(String parameterName) |
UploadFile |
getFile(String parameterName,
String saveDirectory) |
UploadFile |
getFile(String parameterName,
String saveDirectory,
int maxPostSize) |
UploadFile |
getFile(String parameterName,
String saveDirectory,
Integer maxPostSize,
String encoding) |
List<UploadFile> |
getFiles() |
List<UploadFile> |
getFiles(String saveDirectory) |
List<UploadFile> |
getFiles(String saveDirectory,
int maxPostSize) |
List<UploadFile> |
getFiles(String saveDirectory,
Integer maxPostSize,
String encoding)
Get upload file from multipart request.
|
<T> T |
getModel(Class<T> modelClass)
Get model from http request.
|
<T> T |
getModel(Class<T> modelClass,
String modelName)
Get model from http request.
|
String |
getPara()
Get all para with separator char from url
|
String |
getPara(int index)
Get para from url.
|
String |
getPara(int index,
String defaultValue)
Get para from url with default value if it is null or "".
|
String |
getPara(String name)
Returns the value of a request parameter as a String, or null if the parameter does not
exist.
|
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.
|
Map<String,String[]> |
getParaMap()
Returns the values of the request parameters as a Map.
|
Enumeration<String> |
getParaNames()
Returns an Enumeration of String objects containing the names of the parameters contained in
this request.
|
Boolean |
getParaToBoolean()
Get all para from url and convert to Boolean
|
Boolean |
getParaToBoolean(int index)
Get para from url and conver to Boolean.
|
Boolean |
getParaToBoolean(int index,
Boolean defaultValue)
Get para from url and conver to Boolean with default value if it is null.
|
Boolean |
getParaToBoolean(String name)
Returns the value of a request parameter and convert to Boolean.
|
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.
|
Date |
getParaToDate()
Get all para from url and convert to Date
|
Date |
getParaToDate(String name)
Returns the value of a request parameter and convert to Date.
|
Date |
getParaToDate(String name,
Date defaultValue)
Returns the value of a request parameter and convert to Date with a default value if it is
null.
|
Integer |
getParaToInt()
Get all para from url and convert to Integer
|
Integer |
getParaToInt(int index)
Get para from url and conver to Integer.
|
Integer |
getParaToInt(int index,
Integer defaultValue)
Get para from url and conver to Integer with default value if it is null.
|
Integer |
getParaToInt(String name)
Returns the value of a request parameter and convert to Integer.
|
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.
|
Long |
getParaToLong()
Get all para from url and convert to Long
|
Long |
getParaToLong(int index)
Get para from url and conver to Long.
|
Long |
getParaToLong(int index,
Long defaultValue)
Get para from url and conver to Long with default value if it is null.
|
Long |
getParaToLong(String name)
Returns the value of a request parameter and convert to Long.
|
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.
|
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.
|
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.
|
Long[] |
getParaValuesToLong(String name) |
Render |
getRender() |
javax.servlet.http.HttpServletRequest |
getRequest()
Return HttpServletRequest.
|
javax.servlet.http.HttpServletResponse |
getResponse()
Return HttpServletResponse.
|
javax.servlet.http.HttpSession |
getSession()
Return HttpSession.
|
javax.servlet.http.HttpSession |
getSession(boolean create)
Return HttpSession.
|
<T> T |
getSessionAttr(String key)
Return a Object from session.
|
boolean |
isParaBlank(int index)
Return true if the urlPara value is blank otherwise return false
|
boolean |
isParaBlank(String paraName)
Return true if the para value is blank otherwise return false
|
boolean |
isParaExists(int index)
Return true if the urlPara exists otherwise return false
|
boolean |
isParaExists(String paraName)
Return true if the para exists otherwise return false
|
Controller |
keepModel(Class modelClass) |
Controller |
keepModel(Class modelClass,
String modelName) |
Controller |
keepPara()
Keep all parameter's value except model value
|
Controller |
keepPara(Class type,
String... names) |
Controller |
keepPara(Class type,
String name)
Convert para to special type and keep it
|
Controller |
keepPara(String... names)
Keep parameter's value names pointed, model value can not be kept
|
void |
redirect(String url)
Redirect to url
|
void |
redirect(String url,
boolean withQueryString)
Redirect to url
|
void |
redirect301(String url)
Render with url and 301 status
|
void |
redirect301(String url,
boolean withQueryString)
Render with url and 301 status
|
Controller |
removeAttr(String name)
Removes an attribute from this request
|
Controller |
removeCookie(String name)
Remove Cookie with path = "/".
|
Controller |
removeCookie(String name,
String path)
Remove Cookie.
|
Controller |
removeCookie(String name,
String path,
String domain)
Remove Cookie.
|
Controller |
removeSessionAttr(String key)
Remove Object in session.
|
void |
render(Render render)
Render with any Render which extends Render
|
void |
render(String view)
Render with view use default type Render configured in JFinalConfig
|
void |
render(String view,
int status)
Render with view and status use default type Render configured in JFinalConfig
|
void |
renderError(int errorCode)
Render with view and errorCode status configured in JFinalConfig
|
void |
renderError(int errorCode,
Render render)
Render with render and errorCode status
|
void |
renderError(int errorCode,
String view)
Render with view and errorCode status
|
void |
renderFile(File file)
Render with file
|
void |
renderFile(String fileName)
Render with file
|
void |
renderFreeMarker(String view)
Render with freemarker view
|
void |
renderHtml(String htmlText)
Render with html text.
|
void |
renderJavascript(String javascriptText)
Render with javascript text.
|
void |
renderJson()
Render with json
|
void |
renderJson(Object object)
Render json with object.
|
void |
renderJson(String jsonText)
Render with json text.
|
void |
renderJson(String[] attrs)
Render with attributes set by setAttr(...) before.
|
void |
renderJson(String key,
Object value)
Render with json
Example:
renderJson("message", "Save successful"); renderJson("users", users); |
void |
renderJsp(String view)
Render with jsp view
|
void |
renderNull()
Render nothing, no response to browser
|
void |
renderText(String text)
Render with text.
|
void |
renderText(String text,
ContentType contentType)
Render with text and ContentType.
|
void |
renderText(String text,
String contentType)
Render with text and content type.
|
void |
renderXml(String view)
Render with xml view using freemarker.
|
Controller |
setAttr(String name,
Object value)
Stores an attribute in this request
|
Controller |
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
|
Controller |
setCookie(javax.servlet.http.Cookie cookie)
Set Cookie to response.
|
Controller |
setCookie(String name,
String value,
int maxAgeInSeconds)
Set Cookie with path = "/".
|
Controller |
setCookie(String name,
String value,
int maxAgeInSeconds,
String path)
Set Cookie to response.
|
Controller |
setCookie(String name,
String value,
int maxAgeInSeconds,
String path,
String domain)
Set Cookie to response.
|
Controller |
setSessionAttr(String key,
Object value)
Store Object to session.
|
void |
setUrlPara(String urlPara) |
boolean |
validateToken()
Check token to prevent resubmit with default token key ---> "JFINAL_TOKEN_KEY"
|
boolean |
validateToken(String tokenName)
Check token to prevent resubmit.
|
public void setUrlPara(String urlPara)
public Controller setAttr(String name, Object value)
name - a String specifying the name of the attributevalue - the Object to be storedpublic Controller removeAttr(String name)
name - a String specifying the name of the attribute to removepublic Controller setAttrs(Map<String,Object> attrMap)
attrMap - key and value as attribute of the map to be storedpublic 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 parameterpublic 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 nullpublic Map<String,String[]> getParaMap()
public Enumeration<String> getParaNames()
public String[] getParaValues(String name)
name - a String containing the name of the parameter whose value is requestedpublic Integer[] getParaValuesToInt(String name)
name - a String containing the name of the parameter whose value is requestedpublic Enumeration<String> getAttrNames()
public <T> T getAttr(String name)
name - a String specifying the name of the attributepublic String getAttrForStr(String name)
name - a String specifying the name of the attributepublic Integer getAttrForInt(String name)
name - a String specifying the name of the attributepublic Integer getParaToInt(String name)
name - a String specifying the name of the parameterpublic Integer getParaToInt(String name, Integer defaultValue)
name - a String specifying the name of the parameterpublic Long getParaToLong(String name)
name - a String specifying the name of the parameterpublic Long getParaToLong(String name, Long defaultValue)
name - a String specifying the name of the parameterpublic Boolean getParaToBoolean(String name)
name - a String specifying the name of the parameterpublic Boolean getParaToBoolean(String name, Boolean defaultValue)
name - a String specifying the name of the parameterpublic Boolean getParaToBoolean()
public Boolean getParaToBoolean(int index)
public Boolean getParaToBoolean(int index, Boolean defaultValue)
public Date getParaToDate(String name)
name - a String specifying the name of the parameterpublic Date getParaToDate(String name, Date defaultValue)
name - a String specifying the name of the parameterpublic Date getParaToDate()
public javax.servlet.http.HttpServletRequest getRequest()
public javax.servlet.http.HttpServletResponse getResponse()
public javax.servlet.http.HttpSession getSession()
public javax.servlet.http.HttpSession getSession(boolean create)
create - a boolean specifying create HttpSession if it not existspublic <T> T getSessionAttr(String key)
key - a String specifying the key of the Object stored in sessionpublic Controller setSessionAttr(String key, Object value)
key - a String specifying the key of the Object stored in sessionvalue - a Object specifying the value stored in sessionpublic Controller removeSessionAttr(String key)
key - a String specifying the key of the Object stored in sessionpublic String getCookie(String name, String defaultValue)
public Integer getCookieToInt(String name)
public Integer getCookieToInt(String name, Integer defaultValue)
public Long getCookieToLong(String name)
public Long getCookieToLong(String name, Long defaultValue)
public javax.servlet.http.Cookie getCookieObject(String name)
public javax.servlet.http.Cookie[] getCookieObjects()
public Controller setCookie(javax.servlet.http.Cookie cookie)
public Controller 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)public Controller 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 2109public Controller setCookie(String name, String value, int maxAgeInSeconds)
public Controller removeCookie(String name)
public Controller removeCookie(String name, String path)
public Controller removeCookie(String name, String path, String domain)
public String getPara()
public String getPara(int index)
public String getPara(int index, String defaultValue)
public Integer getParaToInt(int index)
public Integer getParaToInt(int index, Integer defaultValue)
public Long getParaToLong(int index)
public Long getParaToLong(int index, Long defaultValue)
public Integer getParaToInt()
public Long getParaToLong()
public <T> T getModel(Class<T> modelClass)
public List<UploadFile> getFiles(String saveDirectory, Integer maxPostSize, String encoding)
public UploadFile getFile(String parameterName, String saveDirectory, Integer maxPostSize, String encoding)
public List<UploadFile> getFiles(String saveDirectory, int maxPostSize)
public UploadFile getFile(String parameterName, String saveDirectory, int maxPostSize)
public List<UploadFile> getFiles(String saveDirectory)
public UploadFile getFile(String parameterName, String saveDirectory)
public List<UploadFile> getFiles()
public UploadFile getFile()
public UploadFile getFile(String parameterName)
public Controller keepPara()
public Controller keepPara(String... names)
public Controller keepPara(Class type, String name)
public Controller keepPara(Class type, String... names)
public Controller keepModel(Class modelClass, String modelName)
public Controller keepModel(Class modelClass)
public void createToken(String tokenName, int secondsOfTimeOut)
tokenName - the token name used in viewsecondsOfTimeOut - the seconds of time out, secondsOfTimeOut >= Const.MIN_SECONDS_OF_TOKEN_TIME_OUTpublic void createToken()
public void createToken(String tokenName)
tokenName - the token name used in viewpublic boolean validateToken(String tokenName)
tokenName - the token name used in view's formpublic boolean validateToken()
public boolean isParaBlank(String paraName)
public boolean isParaBlank(int index)
public boolean isParaExists(String paraName)
public boolean isParaExists(int index)
public Render getRender()
public void render(Render render)
public void render(String view)
public void renderJsp(String view)
public void renderFreeMarker(String view)
public void renderJson(String key, Object value)
Example:
renderJson("message", "Save successful");
renderJson("users", users);
public void renderJson()
public void renderJson(String[] attrs)
Example: renderJson(new String[]{"blogList", "user"});
public void renderJson(String jsonText)
Example: renderJson("{\"message\":\"Please input password!\"}");
public void renderJson(Object object)
Example: renderJson(new User().set("name", "JFinal").set("age", 18));
public void renderText(String text)
public void renderText(String text, String contentType)
Example: renderText("<user id='5888'>James</user>", "application/xml");
public void renderText(String text, ContentType contentType)
Example: renderText("<html>Hello James</html>", ContentType.HTML);
public void forwardAction(String actionUrl)
public void renderFile(String fileName)
public void renderFile(File file)
public void redirect(String url)
public void redirect(String url, boolean withQueryString)
public void render(String view, int status)
public void redirect301(String url)
public void redirect301(String url, boolean withQueryString)
public void renderError(int errorCode,
String view)
public void renderError(int errorCode,
Render render)
public void renderError(int errorCode)
public void renderNull()
public void renderJavascript(String javascriptText)
public void renderHtml(String htmlText)
public void renderXml(String view)
public void checkUrlPara(int minLength,
int maxLength)
public void checkUrlPara(int length)
public <T> T enhance(Class<T> targetClass)
public <T> T enhance(Class<T> targetClass, Interceptor... injectInters)
public <T> T enhance(Class<T> targetClass, Class<? extends Interceptor>... injectIntersClasses)
public <T> T enhance(Class<T> targetClass, Class<? extends Interceptor> injectIntersClass)
public <T> T enhance(Class<T> targetClass, Class<? extends Interceptor> injectIntersClass1, Class<? extends Interceptor> injectIntersClass2)
public <T> T enhance(Class<T> targetClass, Class<? extends Interceptor> injectIntersClass1, Class<? extends Interceptor> injectIntersClass2, Class<? extends Interceptor> injectIntersClass3)
public <T> T enhance(String singletonKey, Class<T> targetClass, Interceptor... injectInters)
public <T> T enhance(String singletonKey, Class<T> targetClass, Class<? extends Interceptor>... injectIntersClasses)
public <T> T enhance(Object target)
public <T> T enhance(Object target, Interceptor... injectInters)
public <T> T enhance(Object target, Class<? extends Interceptor>... injectIntersClasses)
public <T> T enhance(Object target, Class<? extends Interceptor> injectIntersClass)
public <T> T enhance(Object target, Class<? extends Interceptor> injectIntersClass1, Class<? extends Interceptor> injectIntersClass2)
public <T> T enhance(Object target, Class<? extends Interceptor> injectIntersClass1, Class<? extends Interceptor> injectIntersClass2, Class<? extends Interceptor> injectIntersClass3)
public <T> T enhance(String singletonKey, Object target, Interceptor... injectInters)
public <T> T enhance(String singletonKey, Object target, Class<? extends Interceptor>... injectIntersClasses)
Copyright © 2015. All rights reserved.