Package net.paoding.rose.web.annotation

Examples of net.paoding.rose.web.annotation.ReqMethod


        RequestPath curpath = inv.getRequestPath();
        String testUri = inv.getRequest().getQueryString(); // queryString as uri
        if (testUri == null || testUri.length() == 0) {
            return "@e.g. <a href='/rose-info/method?get=/rose-info/tree'>/rose-info/method?get=/rose-info/tree</a>";
        }
        ReqMethod testMethod = curpath.getMethod();
        if (testUri.indexOf('=') > 0) {
            int index = testUri.indexOf('=');
            testMethod = ReqMethod.parse(testUri.substring(0, index));
            testUri = testUri.substring(index + 1);
        }
View Full Code Here


                    (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;
View Full Code Here

TOP

Related Classes of net.paoding.rose.web.annotation.ReqMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.