你应该在tomcat目录下找你的class文件的目录,那是你运行时候的目录,然后对应找你文件的目录就好找了
解决方案 »
- 【求助】为什么html跳转servlet路径老错啊
- 求助Hibernate报错: org.hibernate.MappingException: Unknown entity: com.hibernate.be
- Struts2中 上传时文件时 表单的中文自动删除.
- map判断
- 做ssh出现的异常,。。。。。。。。
- org.hibernate.util.JDBCExceptionReporter - SQL Error: 2289, SQLState: 42000
- struts-2.3.12 给action传参数问题
- struts关于乱码奇怪问题
- jboss平台下ejbql语句中like语句问题?
- ImageIO.write 写入gif 图片 报错 图片黑屏不会动
- tomcat在退出的时候如何能做一些清理动
- 四个J2EE讨论群,都升级为256M高级群,分别讨论STRUTS EJB Servlet XML/JSP邀请各位豪杰加入,一起共享代码和教程
String classNameUrl="/org/apache/commons/dbcp/BasicDataSource.class";
String temp=null;
int i = 0;
try {
Class.forName(className);
java.net.URL classUrl = FilesUtil.class
.getResource(classNameUrl);
temp = classUrl.getPath();
temp = URLDecoder.decode(temp);
if ("Win".equalsIgnoreCase(System.getProperty("os.name").substring(
0, 3))) {
i = 6;
} else {
i = 5;
}
webRoot = temp.substring(i, temp.indexOf("WEB-INF") - 1);
} catch (Exception e) {
UlandLogger.debug("取得webRoot时出错:", e);
webRoot = "";
}是取到目录为webRoot
有了这个目录web应用中所有目录就ok
如我自己的:
/**
* 取到目录为webRoot/xml/
*
* @return
*/
public static String getXmlPath(){
// 取到webRoot/xml/
String path= getWebRoot()+File.separator+"xml"+File.separator;
return path;
}
/**
* 取到目录为webRoot/xml/
*
* @return
*/
public static String getConfigPath(){
// 取到webRoot/xml/
String path= getWebRoot()+File.separator+"config"+File.separator;
return path;
}
多谢你了
我用了session.getServletContext().getRealPath() 可以了,你那个有点复杂,不过还是要谢谢你哈!晚上下班后揭帖
用我说的那样准确.当然,看你了!