代碼片段:
String
prefix = config.getServletContext().getRealPath("/");
if (prefix == null || prefix.equals("")) {
// deployment in weblogic through ear file does not deploy
// phisically
// the files,
// so we need to obtain the path through getClass method
java.net.URL url = this.getClass().getResource("/");
String mSchemaPath = url.getFile();
if (mSchemaPath != null || !mSchemaPath.equals("")) {
String separator = "/";
int lastSlash = mSchemaPath.lastIndexOf(separator);
if (lastSlash == -1) {
separator = "\\";
lastSlash = mSchemaPath.lastIndexOf(separator);
}
prefix = mSchemaPath.substring(0, lastSlash);
prefix = prefix.substring(0, prefix.lastIndexOf(separator));
prefix = prefix.substring(0, prefix.lastIndexOf(separator) + 1);
// lastSlash = mSchemaPath.lastIndexOf(separator);
// mSchemaPath = mSchemaPath.substring(0, lastSlash);
// lastSlash = mSchemaPath.lastIndexOf(separator);
// prefix = mSchemaPath.substring(0, lastSlash+1);
}
}
posted on 2010-12-03 22:06
Ke 阅读(2427)
评论(0) 编辑 收藏 所属分类:
java 、
tomcat