本文整理匯總了Java中javax.servlet.http.HttpServletRequest.getRealPath方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletRequest.getRealPath方法的具體用法?Java HttpServletRequest.getRealPath怎麽用?Java HttpServletRequest.getRealPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.servlet.http.HttpServletRequest
的用法示例。
在下文中一共展示了HttpServletRequest.getRealPath方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dealWithBase64
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public static String dealWithBase64(HttpServletRequest request, String files[]) {
String tmp_htext = "";
String upload_path = request.getRealPath("/uploads");
for(int i=0;i<files.length;i++){
if(files[i]==null)continue;
String NewFileName = new Date().getTime()+""+((char)((Math.random()*26)+97))+((char)((Math.random()*26)+97));
String Ext = getImageExtFromBase64(files[i]);
generateImage(files[i],upload_path,NewFileName,Ext);
tmp_htext += NewFileName+"."+Ext+(i<files.length-1?";":"");
}
return tmp_htext;
}
示例2: getFile
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
* Finds a file relative to the jsp page in which the function is called.
*
* @param relativePath NOT YET DOCUMENTED
* @param request NOT YET DOCUMENTED
* @return The file value
*/
private static File getFile(String relativePath, HttpServletRequest request) {
String servletPath = request.getServletPath();
String realPath = request.getRealPath(servletPath);
File dir = new File(realPath).getParentFile();
File file = new File(dir, relativePath);
return file;
}
示例3: getReqRealPath
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private String getReqRealPath(HttpServletRequest request) {
try {
return request.getServletContext().getRealPath("");
}
catch (Error e) {
return request.getRealPath("");
}
}