当前位置: 代码迷 >> 应用服务器 >> weblogic布署在linux环境上下传图片有关问题
  详细解决方案

weblogic布署在linux环境上下传图片有关问题

热度:4823   发布时间:2013-02-26 00:00:00.0
weblogic布署在linux环境下上传图片问题
weblogic布署在windows下上传图片路径没有问题,但是在linux环境下上传图片问题根本就没有传到expertPhoto/这个目录下
代码如下:
public void save() {
if(expertVO.getPhotoChange().equals("1")){
// String targetDirectory = FileUtil.BASE_UPLOAD_PATH
// + Constants.PATH_SEPARATOR + Constants.EXPERT_PHOTO;
String targetDirectory =System.getProperty("webapp.root")+"/upload/expertPhoto/";

String targetFileName ="";
if(fileName!=null){
targetFileName = generateFileName(fileName);
File target = new File(targetDirectory, targetFileName);
FileUtil.copy(doc, target);
}
expertVO.setPhotoPath(targetFileName);
}
if (expertService.addExpert(expertVO) == 1) {
// 返回操作状态
writeWithFile(true);
return; 
}
writeWithFile(false);
}

请各位是怎么回事啊..?

------解决方案--------------------------------------------------------
webapp.root属性设了吗?System.getProperties();里默认没有。
 如果设了的话注意:在window下路径默认是 "\" ,linux默认是 "/",都转换成“/”就行了,window也支持这种方式。