'Springboot: controller access files through Resource Interface'

Thursday, Sep 10, 2015 | 1分钟阅读 | 更新于 Thursday, Sep 10, 2015

@

Access files through classpath.

Springboot will  scan /META-INF/resources/; /resources/; /static/ and/public/ folders when you tell it to find something in the “Classpath”. 

Using Resource interface would instantiate an ClassPathResource. 

Resource resource =new ClassPathResource("RelativePathOfYourFile, root of  /META-INF/resources/; /resources/; /static/ or /public/");
		
		try {
			String path =resource.getFile().getAbsolutePath();
			
		} catch (IOException e) { 
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

© 2008 - 2025 回忆的故乡

🌱 Powered by Hugo with theme Dream.

About Me

Coding(the Vibe one), Tennis, Portrait Photographer

Boston University Worcester Polytechnic Institute

欢迎来到我的个人博客!