相关getServletContext
有关getServletContext
public void parseRequest(HttpServletRequest request){
System.out.println("parseRequest:"+request.getParameter("username"));
System.out.println("realPath:"+request.getServletContext().getRealPath("/"));
path=request.getServletContext().getRealPath("/test_db.accdb");
ConnectAccessFile(request.getParameter("username"));
}
上面是TestAction.java中的几句,运行提示错误
The method getServletContext() is undefined for the type HttpServletRequest
The method getServletContext() is undefined for the type HttpServletRequest
求助啊!这要怎么解决
------解决思路----------------------
getServletContext()
这个方法在Servlet 3.0规范里才有,你是tomcat6?要tomcat7才行的
------解决思路----------------------
在高版本的servlet中已经不支持这个API了
public void parseRequest(HttpServletRequest request){
System.out.println("parseRequest:"+request.getParameter("username"));
System.out.println("realPath:"+request.getServletContext().getRealPath("/"));
path=request.getServletContext().getRealPath("/test_db.accdb");
ConnectAccessFile(request.getParameter("username"));
}
上面是TestAction.java中的几句,运行提示错误
The method getServletContext() is undefined for the type HttpServletRequest
The method getServletContext() is undefined for the type HttpServletRequest
求助啊!这要怎么解决
------解决思路----------------------
getServletContext()
这个方法在Servlet 3.0规范里才有,你是tomcat6?要tomcat7才行的
------解决思路----------------------
request.getServletContext().getRealPath("/")
在高版本的servlet中已经不支持这个API了