zoukankan      html  css  js  c++  java
  • serlvet HttpServletRequest

    1.http://localhost/az/servlet/TestResponse

    out.print("getServletPath:"+request.getServletPath());  // /servlet/TestResponse
    out.print(",getContextPath:"+request.getContextPath());// /az

    out.print(",getRequestURI:"+request.getRequestURI());// /az/servlet/TestResponse

    out.print(",getRequestURL:"+request.getRequestURL());// http://localhost/az/servlet/TestResponse

    this.getServletContext().getRealPath("/images/arrow.png") //E:SoftWareapache-tomcat-8.0.44webappsamazingclassimagesarrow.png

    out.print(",getServerPort:"+request.getServerPort);// 80

    out.print(",getRemotePort:"+request.getRemotePort);// 50545

     2.参数处理

      

    //request对象封装的参数是以Map的形式存储的
            Map<String, String[]> paramMap = request.getParameterMap();
            for(Map.Entry<String, String[]> entry :paramMap.entrySet()){
                String paramName = entry.getKey();
                String paramValue = "";
                String[] paramValueArr = entry.getValue();
                for (int i = 0; paramValueArr!=null && i < paramValueArr.length; i++) {
                    if (i == paramValueArr.length-1) {
                        paramValue+=paramValueArr[i];
                    }else {
                        paramValue+=paramValueArr[i]+",";
                    }
                }
                System.out.println(MessageFormat.format("{0}={1}", paramName,paramValue));
            }
  • 相关阅读:
    ListView
    Android 控件知识点
    Android之alertDialog、ProgressDialog
    Android 控件知识点,
    知晓当前是哪一个活动
    Activity的启动模式
    iOS9之Bitcode
    Xcode7免证书真机调试实践
    XCode6之后预编译文件的创建
    Swift计算文本宽高
  • 原文地址:https://www.cnblogs.com/newlangwen/p/7777708.html
Copyright © 2011-2022 走看看