项目要求我下载war包中的文件,我在本地用weblogic发布module的时候可以实现从工程目录中下载,但是打成war包后,用weblogic发布的时候却抛FileNotFound Exception,请各位看看帮忙解决,不胜感激。
public static String getFileName( String pathKey, String fileNmKey, HttpServlet servlet) { String configBundleNm = "存放文件路径及文件名的资源文件名"; String fullName = null;
try { PropertyResourceBundle configBundle = (PropertyResourceBundle) PropertyResourceBundle.getBundle( configBundleNm, Locale.getDefault());
String fileName = (String) configBundle.getString(fileNmKey).trim(); String path = (String) configBundle.getString(pathKey).trim(); String fullPath = servlet.getServletContext().getRealPath(path); String fileSeparator = System.getProperties().getProperty("file.separator"); fullName = new StringBuffer() .append(fullPath) .append(fileSeparator) .append(fileName) .toString(); } catch (MissingResourceException missE) {
}
File file = new File(fullName); if (!file.isFile()) {
}
return fullName;
}
|