Java tutorial
/* * Copyright 2014 Aliyun.com All right reserved. This software is the * confidential and proprietary information of Aliyun.com ("Confidential * Information"). You shall not disclose such Confidential Information and shall * use it only in accordance with the terms of the license agreement you entered * into with Aliyun.com . */ package com.resource; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ResourceLoaderAware; import org.springframework.core.io.ResourceLoader; /** * Created by xiaotao.wxt on 2014/12/5. */ public class ResourceLoaderInjection3 implements ApplicationContextAware { private ApplicationContext applicationContext; public void getResource(String location) throws Exception { System.out.println(applicationContext.getResource(location).getURL()); } @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } }