语法:在:与value之间有空格
key: value
取属性的值:
1.取单个值:使用@Value注解取值
1.1 测试类代码:
import cd.zf.test.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.Map;
@Controller
public class PageTest {
@Autowired
private UserDao userDao;
@Value("${page.rows}")
private Integer rows;
@RequestMapping("/pageRows")
@ResponseBody
public Map showRows(){
Map map = new HashMap();
map.put("rows",rows);
return map;
}
}
1.2 在src/m