springboot访问access可以写相对路径吗

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot访问access可以写相对路径吗相关的知识,希望对你有一定的参考价值。

参考技术A springboot访问access可以写相对路径。
springboot访问access写相对路径的方法如下:
string dataDir = AppDomain.CurrentDomain.BaseDirectory;
if (dataDir.EndsWith(@"\\bin\\Debug\\")
|| dataDir.EndsWith(@""\\bin\\Release\\""))

dataDir = System.IO.Directory.GetParent(dataDir).Parent.Parent.FullName;
AppDomain.CurrentDomain.SetData(""DataDirectory""

相对路径和绝对路径

比如说一个名为image.jpg的图片

相对路径是这么写:url=‘./image.jpg‘  或 url=‘image.jpg‘

绝对路径是这么写: url=‘/image.jpg‘ 前面是有一个斜杠的

浏览器在绝对地址前是不会加上基础路径的,这样浏览器就会访问 http://localhost:8080/cdef.jpg

 

以上是关于springboot访问access可以写相对路径吗的主要内容,如果未能解决你的问题,请参考以下文章

SVN使用技巧:[2]SVN用户权限设置

java web项目 相对路径怎么写

spring boot路径问题

spring boot上下文路径写在哪

Python文件操作与集合

Springboot项目创建文件中相对路径问题