Share on Google+Share on Google+

Spring Props Tag, Spring prop key, Spring props prop

In this spring tutorial you will see the example of spring props tags.

Spring Props

The Spring Framework has bean support for the Collections. It provide list, set, map and props elements. Here in this tutorial you will see about the props elements which is used to set values into   the properties.

package collection.props.example;

import java.util.Properties;

public class CollegeBean {
  private Properties pros;

  public Properties getPros() {
    return pros;

  public void setPros(Properties pros) {
    this.pros = pros;

  public String toString() {
    return "College [Props=" + pros + "]";

package collection.props.example;

import org.springframework.beans.factory.BeanFactory;

public class PropsMain {
  public static void main(String[] args) {
    BeanFactory beanfactory = new ClassPathXmlApplicationContext(
    CollegeBean coll = (CollegeBeanbeanfactory.getBean("collegeBean3");

  <!-- Spring Props -->

  <bean id="collegeBean3" class="collection.props.example.CollegeBean">
    <property name="pros">
        <prop key="roll">100</prop>
        <prop key="name">satya</prop>

  <!-- End -->

When you run this application it will display output as shown below:

College [Props={roll=100, name=satya}]

Download this example code


Posted on: August 13, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null