request.getServletContext()的问题!

ServletRequest的getServletContext方法是Servlet3.0添加的,这个可以看一下官方文档

http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getServletContext()

而Tomcat6只支持到Servlet2.5看它的官方文档可以知道,要用J2EE6的话得换成Tomcat7

http://tomcat.apache.org/tomcat-6.0-doc/index.html

旧版本需要先用request拿到HttpSession或者通过Servlet自身拿到ServletConfig之后再获取ServletContext

posted @ 2014-01-06 16:52  google4y  阅读(1565)  评论(1编辑  收藏  举报
不在家,就在公司,不在公司,就在去公司的路上,無家無根,如風如萍,只有漂