String path = ServletActionContext.getServletContext().getRealPath(baseDir);//获取baseDir的物理路径
报错:Multiplemarkersatthisline-Thetypejavax.servlet.ServletContextcannotberesolved.Itis...
报错:
Multiple markers at this line
- The type javax.servlet.ServletContext cannot be resolved. It is indirectly referenced
from required .class files
- The method getServletContext() from the type ServletActionContext refers to the missing
type ServletContext 展开
Multiple markers at this line
- The type javax.servlet.ServletContext cannot be resolved. It is indirectly referenced
from required .class files
- The method getServletContext() from the type ServletActionContext refers to the missing
type ServletContext 展开
1个回答
展开全部
//得到绝对路径
String path=this.getServletContext().getRealPath("/WEB-INF/classes/db.properties");
//用传统代码读,通常用在下载(可以得到资源名称)
String filename=path.substring(path.lastIndexOf("\\")+1);
System.out.println("资源名称:"+filename);
String path=this.getServletContext().getRealPath("/WEB-INF/classes/db.properties");
//用传统代码读,通常用在下载(可以得到资源名称)
String filename=path.substring(path.lastIndexOf("\\")+1);
System.out.println("资源名称:"+filename);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询