ServletActionContext
2017-12-09 本文已影响0人
黎涛note
在程序中可使用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);