springmvc配置properties文件

properties文件是Java文件中比较常见的文件,将数据集中在文件,经过配置直接读取html

此篇记录的只是一种配置方法,有多种配置方法,spring

可参考:https://hy90171.iteye.com/blog/1868006express

https://www.cnblogs.com/yucongblog/p/7338896.html后端

1.在applicationContext中配置:app

<context:property-placeholder location="classpath:properties/*.properties" />
 <util:properties id="urlprop" location="classpath:properties/url.properties"/>jsp

也可配置多个properties文件url

读取方式:spa

jsp页面:htm

利用标签读取blog

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<spring:eval expression="@urlprop['url']" var="url"/>

  <img src="//${url}/不一样的路径

后端取值:

@Value("#{urlprop.url}")
    private String urlImgDomain;

可是定义的变量不能够用static定义,以上就是配置+注解方式配置

也有用$符号取值的,可是配置会有不一样,须要之后慢慢积累更新

相关文章
相关标签/搜索