1 2 3 4 5 6 7 8 |
//HttpServletRequest 对象通过以下方法来获取请求路径,如下所示: String serverName = request.getServerName();//获取服务器名,127.0.0.1; int serverPort = request.getServerPort();//获取服务器端口号,8083; String contextPath = request.getContextPath();//获取项目名,/Aop; String ServletPath=request.getServletPath();//获取Servlet路径,/getUserDetails/45; String QueryString=request.getQueryString();//获取参数部分,即问号后面的部分:username=zhangsan StringBuffer RequestURL=request.getRequestURL();//获取请求URL,等于不包含参数的整个请求路径:http://localhost:8083/Aop/getUserDetails/45 String RemoteAddr=request.getRemoteAddr();//获取服务器的IP,如localhost对应ip为127.0. |
from:https://www.cnblogs.com/zhoading/p/13954370.html
View Details // 指定文件或文件夹的路径
Path path = Paths.get("path/to/your/file_or_directory");
// 检查路径是否存在,并且是一个文件(不是文件夹)
boolean isFile = Files.exists(path, LinkOption.NOFOLLOW_LINKS) && Files.isRegularFile(path);
// 检查路径是否存在,并且是一个文件夹(不是文件)
boolean isDirectory = Files.exists(path, LinkOption.NOFOLLOW_LINKS) && Files.isDirectory(path);