1,数据库中保存的附件路径; eg D:\xgxt\files
String fjSavePath = getSavePath();
private String getSavePath() {
RowSetIterator rs = null;
try {
ApplicationModule am = this.getApplicationModule();
ViewObject vo = am.findViewObject("XtglXtszView1");
vo.setWhereClause("Blm = 'FJPATH'");
rs = vo.createRowSetIterator("yy");
String blz = rs.first().getAttribute("Blz").toString();
return blz;
} catch (Exception e) {
// TODO: Add catch code
e.printStackTrace();
} finally {
if (rs != null) {
rs.closeRowSetIterator();
}
}
return null;
}
2,项目根路径
public static String LSZPWJJ = JSFUtils.getRealPath()+ "/jwxtjsgl/image"; //临时照片文件夹(自定义路径)
/**
* 获取当前工程的根目录
* @return
*
*/
public static String getRealPath(){
FacesContext fctx = FacesContext.getCurrentInstance();
ServletContext servletCtx =
(ServletContext)fctx.getExternalContext().getContext();
String dirPath = servletCtx.getRealPath("/");
return dirPath;
}
这里的根目录路径是发布空间的路径 eg
D:\JDevRuntime1213\system12.1.3.0.41.140521.1008\o.j2ee\drs\xgxt\KnsglViewControllerWebApp.war\