spring-boot: uri和url


 ClassPathResource resource = new ClassPathResource("static/one_3.jpg");

//        InputStream inputStream = resource.getInputStream();

        String uri = "uri = " + resource.getURI().getPath();


        String path = "path = " + resource.getPath();

        String file = " file = " + resource.getFile().getAbsolutePath();


        String url = "url = " + resource.getURL().toString();

        logger.info(uri);
        logger.info(path);
        logger.info(file);
        logger.info(url);

url:前缀格式:

file:
http:
https:
ftp:

url = file:/Users/benjamin/opt/tomcat-8.5.37/webapps/access-resources-0.0.1-SNAPSHOT/WEB-INF/classes/static/one_3.jpg

uri: 没有前缀

uri = /Users/benjamin/opt/tomcat-8.5.37/webapps/access-resources-0.0.1-SNAPSHOT/WEB-INF/classes/static/one_3.jpg

你可能感兴趣的:(spring-boot: uri和url)