配置文件 .properties 的使用。
在代码中使用
@Controller
public class IndexController { @Value("${CONTENT_LUNBO_ID}")
private Long CONTENT_LUNBO_ID; @Autowired
private ContentService contentService; @RequestMapping("/index")
public String showIndex(Model model) {
//查询内容列表
List<TbContent> ad1List = contentService.getContentListByCid(CONTENT_LUNBO_ID);
// 把结果传递给页面
model.addAttribute("ad1List", ad1List);
return "index";
}
}
.properties
CONTENT_LUNBO_ID=89
在springMVC中加载:
<!-- 加载配置文件 -->
<context:property-placeholder location="classpath:conf/resource.properties" />
配置文件 .properties 的使用。的更多相关文章
- 操作配置文件Properties
// */ // ]]> 操作配置文件Properties Table of Contents 1 定义 2 读取配置值 3 修改和保存配置 4 注意 1 定义 csharp中在Settin ...
- 复习课程jdbc:使用配置文件properties进行连接数据库,数据库存取图片,批处理,时间戳,事物回滚等等
使用配置文件properties进行连接数据库 首先创建一个file自定义文件名,但是后缀名必须改为.properties(不分大小写):如config.properties: 然后双击config. ...
- Java配置文件Properties的读取、写入与更新操作
/** * 实现对Java配置文件Properties的读取.写入与更新操作 */ package test; import java.io.BufferedInputStream; import j ...
- 【转】spring管理属性配置文件properties——使用PropertiesFactoryBean|spring管理属性配置文件properties——使用PropertyPlaceholderConfigurer
spring管理属性配置文件properties--使用PropertiesFactoryBean 对于属性配置,一般采用的是键值对的形式,如:key=value属性配置文件一般使用的是XXX.pr ...
- 对Java配置文件Properties的读取、写入与更新操作
http://breezylee.iteye.com/blog/1340868 对Java配置文件Properties的读取.写入与更新操作 博客分类: javase properties 对Jav ...
- 实现对Java配置文件Properties的读取、写入与更新操作
/** * 实现对Java配置文件Properties的读取.写入与更新操作 */ package test; import java.io.BufferedInputStream; import j ...
- 读取配置文件properties的几种方式
介绍几种读取方式:参考:https://www.cnblogs.com/sebastian-tyd/p/7895182.html .基于ClassLoder读取配置文件 注意:该方式只能读取类路径下的 ...
- 6.12-PrepareStatement,JdbcUtil 读取数据库配置文件properties,dao模式
一.PrepareStatement 防止sql注入 PrepareStatement 是预编译sql语句 更加灵活,更有效率 executeUpdate() 做增删改 executeQuery() ...
- 读取java配置文件properties
java项目里很多参数都是写在配置文件properties上,如果需要读取的话,可以使用jdk里提供的Properties类进行处理. 具体写法如下: public class PropertiesC ...
- spring boot 配置文件properties和YAML详解
spring boot 配置文件properties和YAML详解 properties中配置信息并获取值. 1:在application.properties配置文件中添加: 根据提示创建直接创建. ...
随机推荐
- MySQL Inception--安装
========================================== 安装依赖包 ## 安装依赖包 yum -y install cmake libncurses5-dev libss ...
- mysql 行号 获取指定行数据
mysql 行号的实现 Select id,(@rowNum:=@rowNum+1) as rowNo From first,(Select (@rowNum :=0) ) bOrder by fir ...
- FastAdmin 使用 Git 更新的新用法 (2019-02-28)
FastAdmin 使用 Git 更新的新用法 2019-02-28 新流程 增加一个 fastadmin 的远程仓库. 在项目的开发或主分支. 如果有代码更新将代码提交 commit. git pu ...
- zz 牛人啊
http://www.newsmth.net/nForum/#!article/CouponsLife/184517019:57:33cutepig 2015/6/9 19:57:33 http:// ...
- 【转】Android开源项目(非组件)
原文网址:http://blog.csdn.net/feizhixuan46789/article/details/9252887 学习开发一个有效的途径就是借鉴成熟的案例作为学习的对象,下面为大家推 ...
- 二分法查找 (Binary Search)
二分法查找适用于排列有序的数据.java实现方法如下: // Find the location of a value in array a // Array a must be sorted // ...
- hosts,No web site is configured at this address.
解决办法: IIS管理器->右击网站->属性->网站——>IP地址一项->选择全部未分配-> 确定关闭 问题解决.
- linux 搭建 redis
找了很多教程总有一个适合我 http://www.cnblogs.com/_popc/p/3684835.html 当然我的目录是/opt/redis 文章中的目录是/usr/local/redi ...
- Zabbix二次开发_03api列表_中文版
基于ZABBIX 3.0 https://www.zabbix.com/documentation/3.0/manual/api/reference 参考方法 本节提供了的zabbix提供的功能的概述 ...
- Java网络编程(读书笔记)
部分片段: 早期web服务器由于Http链接短暂而有所掩盖,由于web页面和嵌入式的图片一般很小(至少与通常通过FTP获取软件包要小很多),由于web浏览器在获取各个文件后挂起连接,而不是一次保持数分 ...