简体   繁体   中英

How can I use the Absolute Path in Spring for my JSP form?

I save these images in my Folder "C:/test" but I can't load them from it beacuse it's outside the project and I NEED an absolute path Location for others PCs.

This is my Config Class:

@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/test/**").addResourceLocations("file:///./test/");
    }//close addResourceHandlers

This is my JSP:

<img src="<c:url value='C:/test/${employee.documentLinkStr}'/>

What do I have to do?

UPDATE (this work for me).

CONFIG:

 @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry.addResourceHandler("/yourFolder/**").addResourceLocations("file:///C:/yourFolder/");
}//close addResourceHandlers

JSP:

<img src="<c:url value='/yourFolder/${employee.documentLinkStr}'/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM