The explaination of hello2

Posted cheneywxy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了The explaination of hello2相关的知识,希望对你有一定的参考价值。

String username = request.getParameter("username");

//声明一个string变量,并将“username”中的值返回给它

//获取前端传来的参数值.

//这里的request应该在servlet容器中

//通过容器传递给当前httpservlet
            if (username != null && username.length() > 0) {
                RequestDispatcher dispatcher =
                        getServletContext().getRequestDispatcher("/response");
 //通过当前context

//获取url为/response的servlet作为一个dispatcher资源


                if (dispatcher != null) {
                    dispatcher.include(request, response);

//将当前的request,response资源包含到dispatcher用于响应
//其实就是在dispatcher中通过request获得username

//然后在response中添加了hello这几句话

//(这里的dispatcher就是开始获得的/response对应的httpservlet)
                }
            }
            out.println("</body></html>");
        }
    }

以上是关于The explaination of hello2的主要内容,如果未能解决你的问题,请参考以下文章