zoukankan      html  css  js  c++  java
  • java Resource

    ClassPathResource:

      String resource = ""; //相对路径

      Resource resource = new ClassPathResource(resource);

      //获取当前类下,同一个包中的资源

      Resource resource = new ClassPathResource("文件名称",this.getClass());

    FileSystemResource:

      String resource = "";

      //文件系统的真实路径

       Resource resource = new FileSystemResource(resource);

    UrlResource:

        String resource = "httP://...";

          resource = "file://c:/applic...";

         Resource resource = new UrlResource("file://c:/applicationContext.xml");

    ServletContextResource:

      需要在web环境中才可以

       Resource resource = new ServletContextResource(servletContext,"/WEB-INF/classes/applicationContext.xml");

    我们在使用spring容器的时候,由于applicationContext是beanFactory子类,封装了更多方法功能供我们调用,所以在使用applicationContext时,会使用特定格式的字符串表示各种类型

    classPath:loaded from the classpath

    file:loaded as a URL,from the fileSystem

    http:  loaded as a URL

    none   /data/config.xml    Depends on the underlying ApplicationContext

  • 相关阅读:
    C#面向对象--类
    Unity DOTS--面向数据编程前的准备
    C#面向对象--命名空间
    C#面向对象--多态
    C#面向对象--继承
    C#中堆和栈的区别
    sql执行顺序
    cookie session
    栈和队列
    c# 单例模式
  • 原文地址:https://www.cnblogs.com/cr1719/p/3841853.html
Copyright © 2011-2022 走看看