本文整理汇总了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("");
}
}