(invocationCtxpath == null ? getCtxpath() : invocationCtxpath).length()));
}
}
private ReqMethod parseMethod(HttpServletRequest request) {
ReqMethod reqMethod = ReqMethod.parse(request.getMethod());
if (reqMethod != null && reqMethod.equals(ReqMethod.POST)) {
// 为什么不用getParameter:
// 1、使_method只能在queryString中,不能在body中
// 2、getParameter会导致encoding,使用UTF-8? 尽量不做这个假设
String queryString = request.getQueryString();
if (queryString != null) {
boolean methodChanged = false;
int start = queryString.indexOf("_method=");
if (start == 0 || (start > 0 && queryString.charAt(start - 1) == '&')) {
int end = queryString.indexOf('&', start);
String method = queryString.substring(start + "_method=".length(),//
end > 0 ? end : queryString.length());
ReqMethod _reqMethod = ReqMethod.parse(method);
if (_reqMethod != null) {
if (logger.isDebugEnabled()) {
logger.debug("override http method from POST to " + _reqMethod);
}
reqMethod = _reqMethod;
methodChanged = true;
}
}
if (!methodChanged) {
int inBodyStart = queryString.indexOf("_method_in_body=1");
if (inBodyStart == 0
|| (inBodyStart > 0 && queryString.charAt(inBodyStart - 1) == '&')) {
String method = request.getParameter("_method");
ReqMethod _reqMethod = ReqMethod.parse(method);
if (_reqMethod != null) {
if (logger.isDebugEnabled()) {
logger.debug("override http method from POST to " + _reqMethod);
}
reqMethod = _reqMethod;