public class MvcRequest
extends javax.servlet.http.HttpServletRequestWrapper
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
CALLBACK_PARAM
全局的 callback 参数名
|
| 构造器和说明 |
|---|
MvcRequest(javax.servlet.http.HttpServletRequest req)
创建一个 MVC 请求对象。
|
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
clean()
清空 request 和 response
|
String |
getBasePath()
返回协议+主机名+端口+项目前缀(如果为 80 端口的话就默认不写 80)
|
<T> T |
getBean(Class<T> clz)
支持自动获取请求参数并封装到 Bean 内
|
String |
getFolder()
目录部分
|
static javax.servlet.http.HttpServletRequest |
getHttpServletRequest()
获取请求对象
|
static javax.servlet.http.HttpServletResponse |
getHttpServletResponse()
获取上下文中 response 对象
|
String |
getIdOnly(String key)
返回 SQL 类型安全的参数,必须为数字
|
String |
getIp()
获取请求 ip
|
Map<String,Object> |
getMap() |
static MvcRequest |
getMvcRequest()
获取请求对象
|
String |
getParameter(String key,
String defaultValue)
获取参数的值。
|
Map<String,Object> |
getPutRequestData()
获取 PUT 请求所提交的内容。
|
String |
getRequestURI()
绑定 JSP 时候,获取原请求的 uri,而非模版所在的 uri
|
String |
getRoute()
获取资源 URI,忽略项目前缀和最后的文件名(如 index.jsp) 分析 URL 目标资源(最原始的版本)
|
String |
getValueFromPath(String value,
String param)
去取 url 上的值
|
boolean |
hasParameter(String key)
如果有这个参数返回 true。
|
static String |
mappath(javax.servlet.ServletContext cxt,
String relativePath)
获取磁盘真實地址
|
String |
mappath(String relativePath)
输入一个相对地址,补充成为绝对地址 相对地址转换为绝对地址,并转换斜杠
|
void |
saveToReuqest(Map<String,Object> map)
保存到 request
|
static void |
setHttpServletRequest(javax.servlet.http.HttpServletRequest req)
保存一个 request 对象
|
static void |
setHttpServletResponse(javax.servlet.http.HttpServletResponse resp)
保存一个 response 对象
|
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole, login, logout, upgradegetAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsyncclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsyncpublic MvcRequest(javax.servlet.http.HttpServletRequest req)
req - 原始请求对象public String getRequestURI()
getRequestURI 在接口中 javax.servlet.http.HttpServletRequestgetRequestURI 在类中 javax.servlet.http.HttpServletRequestWrapperpublic String getRoute()
public String getFolder()
public Map<String,Object> getPutRequestData()
public String getValueFromPath(String value, String param)
value - 方法上的路径param - 参数名称public <T> T getBean(Class<T> clz)
T - Bean 类型clz - Bean 的类引用public static void setHttpServletRequest(javax.servlet.http.HttpServletRequest req)
req - 请求对象public static javax.servlet.http.HttpServletRequest getHttpServletRequest()
public static MvcRequest getMvcRequest()
public static void setHttpServletResponse(javax.servlet.http.HttpServletResponse resp)
resp - 响应对象public static javax.servlet.http.HttpServletResponse getHttpServletResponse()
public static void clean()
public static String mappath(javax.servlet.ServletContext cxt, String relativePath)
cxt - Web 上下文relativePath - 相对地址public String mappath(String relativePath)
relativePath - 相对地址,例如 /imagespublic String getBasePath()
public String getIp()
public boolean hasParameter(String key)
key - 键名称public String getParameter(String key, String defaultValue)
key - 键名称defaultValue - 若为 null 时的默认值Copyright © 2013–2021 AJAXJS. All rights reserved.