怎么把以下的绝对路径转成相对路径
<%!////Filename:Common.jspstaticfinalStringCRLF="\r\n";staticfinalintUNDEFINT=Integer...
<%! // // Filename: Common.jsp static final String CRLF = "\r\n"; static final int UNDEFINT=Integer.MIN_VALUE; static final int adText = 1; static final int adDate = 2; static final int adNumber = 3; static final int adSearch_ = 4; static final int ad_Search_ = 5; static final String appPath ="/"; //Database connection string static final String DBDriver ="sun.jdbc.odbc.JdbcOdbcDriver"; static final String strConn ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/BookStore_DATA.mdb"; static final String DBusername=""; static final String DBpassword=""; public static String loadDriver () { String sErr = ""; try { java.sql.DriverManager.registerDriver((java.sql.Driver)(Class.forName(DBDriver).newInstance())); } catch (Exception e) { sErr = e.toString(); } return (sErr); } public static void absolute(java.sql.ResultSet rs, int row) throws java.sql.SQLException{ ......
展开
1个回答
展开全部
JSP中获得当前应用的相对路径和绝对路径 根目录所对应的绝对路径:request.getRequestURI() 文件的绝对路径 :application.getRealPath(request.getRequestURI()); 当前web应用的绝对路径 :application.getRealPath("/"); 取得请求文件的上层目录:new File(application.getRealPath(request.getRequestURI())).getParent() 追问: 能不能直接帮我改? 我就是。。不会用 回答: static final String strConn ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/BookStore_DATA.mdb"; 改 static final String strConn ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=application.getRealPath(request.getRequestURI('BookStore_DATA.mdb'))";
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询