解决spring 定时任务中调用context 报错误NullPointer....获取项目路径

import javax.servlet.ServletContext;
import org.apache.struts2.util.ServletContextAware;
import com.opensymphony.xwork2.ActionSupport;
 
public class CustomerAction 
    extends ActionSupport implements ServletContextAware{
 
    ServletContext context;
 
    public String execute() throws Exception {
       String path = context.getRealPath("/");
        return SUCCESS;
 
    }
 
    public void setServletContext(ServletContext context) {
        this.context = context;
    }
}

你可能感兴趣的:(解决spring 定时任务中调用context 报错误NullPointer....获取项目路径)