zoukankan      html  css  js  c++  java
  • spring3中新增的@value注解

    在spring 3.0中,可以通过使用@value,对一些如xxx.properties文件 
    中的文件,进行键值对的注入,例子如下: 

    1 首先在applicationContext.xml中加入: 
       <beans xmlns:util="http://www.springframework.org/schema/util"  
        xsi:schemaLocation="http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">  
    </beans>  
      
       的命名空间,然后 

    2  <util:properties id="settings" location="WEB-INF/classes/META-INF/spring/test.properties" />  

    3 创建test.properties 
       abc=123 

    4 
    import org.springframework.beans.factory.annotation.Value;   
    import org.springframework.stereotype.Controller;   
    import org.springframework.web.bind.annotation.RequestMapping;   
      
    @RequestMapping("/admin/images")   
    @Controller   
    public class ImageAdminController {   
      
        private String imageDir;   
        @Value("#{settings['test.abc']}")   
        public void setImageDir(String val) {   
            this.imageDir = val;   
        }   
      

     
    这样就将test.abc的值注入了imageDir中了

  • 相关阅读:
    jQuery的实用技巧
    jQuery中的Ajax
    jQuery中的动画
    jQuery中的事件
    jQuery中的DOM操作
    详解jQuery的选择器
    微信小程序开发教程(九)视图层——.wxss详解
    微信小程序开发教程(八)视图层——.wxml详解
    14 组合查询
    13 创建高级联结
  • 原文地址:https://www.cnblogs.com/duffy/p/4332407.html
Copyright © 2011-2022 走看看