Spring中怎么设置普通属性值-创新互联

这篇文章将为大家详细讲解有关Spring中怎么设置普通属性值,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名与空间、网络空间、营销软件、网站建设、柯桥网站维护、网站推广。

一 配置

                           

二 Bean

package org.crazyit.app.service;public class ExampleBean{   // 定义一个int型的成员变量   private int integerField;   // 定义一个double型的成员变量   private double doubleField;   // integerField的setter和getter方法   public void setIntegerField(int integerField)   {      this.integerField = integerField;   }   public int getIntegerField()   {      return this.integerField;   }   // doubleField的setter和getter方法   public void setDoubleField(double doubleField)   {      this.doubleField = doubleField;   }   public double getDoubleField()   {      return this.doubleField;   }}

三 测试类

package lee;import org.springframework.context.*;import org.springframework.context.support.*;import org.crazyit.app.service.*;public class BeanTest{  public static void main(String[] args)  {    //以类加载路径下的bean.xml文件来创建Spring容器    ApplicationContext ctx = new      ClassPathXmlApplicationContext("beans.xml");    ExampleBean b = ctx.getBean("exampleBean"      , ExampleBean.class);    System.out.println(b.getIntegerField());    System.out.println(b.getDoubleField());  }}

四 测试结果

12.3

关于Spring中怎么设置普通属性值就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


网站题目:Spring中怎么设置普通属性值-创新互联
转载来于:http://ybzwz.com/article/ddicgs.html