美文网首页
ServletActionContext

ServletActionContext

作者: 黎涛note | 来源:发表于2017-12-09 23:15 被阅读0次

    在程序中可使用ServletActionContext类中的静态方法获取和Servlet相关的对象。
    如:

    public static ServletContext getServletContext();
    public static HttpServletRequest getRequest();
    public static HttpServletResponse getResponse() ;
    

    【示例】获取文件夹的物理路径

    String path = Servlet.getServletContext().getReALpath("/photo");
    System.out.println("path:" + path);
    

    相关文章

      网友评论

          本文标题:ServletActionContext

          本文链接:https://www.haomeiwen.com/subject/ngxmixtx.html