struts2 获取servlet 的相关方法

    	//获得request
     HttpServletRequest request = ServletActionContext.getRequest(); 
    	String contextPath = request.getContextPath();

      //获得session
	    HttpSession session = ServletActionContext.getRequest().getSession();
            
         //获得实际的文件路径
    String path = ServletActionContext.getServletContext().getRealPath("/");


 

你可能感兴趣的:(servlet)