问题是这样的,一个业务处理的类,没有extends HttpServlet,其中的一个方法要得到ServletConfig,这个可能吗?具体看下面的关键代码:public class SaveAction {//没有extends HttpServlet
……
public void excute(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException,ActionException,Exception{ ServletConfig config = ????
}
}
由于没有extends HttpServlet,所以没办法“ServletConfig config = getServletConfig();”,那我怎么办能得到这个ServletConfig ?
……
public void excute(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException,ActionException,Exception{ ServletConfig config = ????
}
}
由于没有extends HttpServlet,所以没办法“ServletConfig config = getServletConfig();”,那我怎么办能得到这个ServletConfig ?
解决方案 »
- hibernate.cfg.xml not found怎么回事啊!
- 【求助】开发是一个日积月累的过程
- 在Firefox中执行javascrip时报错了,请教!
- 求解:hibernate使用sql-query标签如何添加过滤条件.
- 在写jsp时用到session 提示错误
- 请问:如何给request或response手动增加一个header?
- javabean中request范围和session范围的区别到底是什么呢
- Flex与java通信
- 更改web.xml后报资源无法得到,请教各位大虾,在线等待!!!!!
- 如何配置和调试servlet Web应用程序?
- 急!急!急!急!com.jspsmart.upload.SmartUploadException: File can't be saved (1120).
- 关于jsp和php效率问题
分发请求的servlet里:
ServletConfig config = getServletConfig();
把调用的方法excute(request, response);改成excute(request, response, config);public class SaveAction {//没有extends HttpServlet
……
public void excute(HttpServletRequest request, HttpServletResponse response, ServletConfig config) throws IOException, ServletException,ActionException,Exception{//加上ServletConfig config //config 可以直接用了,我是用在SmartUpload的初始化里
mySmartUpload.initialize(config,request,response);
}
}
用ServletConfig config = servlet.getServletConfig();就可以得到 了啊