STRUST 项目中的 ServletConfig.getServletContext() 无法得到? 今天在STRUST 项目中的 action 中 用到了 request.getRealPath("/photo/"+name+".gif")发现函数request.getRealPath 不建议使用,要求用ServletContext 中的这个方法。可是这个类的实例要求用 ServletConfig.getServletContext() 才能获得。之后,我发现只有继承implements Servlet 借口才能 的到ServletConfig 实例。于是我就:public class UserManagerAction extends Action implements Servlet{...public void init(ServletConfig config) throws ServletException {this.config=config;}}在其中,我实现这个congif! 并希望通过他得到ServletContext 实例,这样我得目的就达到了。。。没想到,最后运行时,却出现异常。异常的原因就发生在 :ServletContext sc=config.getServletContext();这。请问,我怎么才能获得 ServletContext 实例?