/**
*获取项目resource下面的config文件
*/
String classesPath = RedisUtil.class.getClassLoader().getResource("").getPath();
String filePath = classesPath + "jedis.properties";
/**
*获取项目web-root下面的文件 例如获取web-root下的file目录
*/
String realPath = getRequest().getSession().getServletContext().getRealPath("")+ File.separator + "file";
/**
*获取http请求的所有参数
*/
public static Map<String, String> paramToMap(HttpServletRequest request) {
HashMap<String, String> map = new HashMap<String, String>();
Map<String, String[]> m = request.getParameterMap();
for (Entry<String, String[]> entry : m.entrySet()) {
map.put(entry.getKey().toString(), entry.getValue()[0]);
}
return map;
}
java获取项目的路径以及请求的路径
最新推荐文章于 2023-01-11 10:44:53 发布