Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7032853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:59:17+00:00 2026-05-28T00:59:17+00:00

Given an inline list from a properties file: nameList=john,smith,junior From the bean definition file,

  • 0

Given an inline list from a properties file:

nameList=john,smith,junior

From the bean definition file, I want to always extract the first item in my list. In this case, I would extract ‘john’.

Using Spring Framework 3.0.4.RELEASE, my bean property looks as follows:

<property name="mySingleName" value="${nameList}" />

This obviously gives me the whole list.

I attempted to use the following to get the first item in the name list, but was met with an error:

<property name="mySingleName" value="#{${nameList}[0]}" />

The error was:

BeanExpressionException:Exception parsing failed: After parsing a valid expression, there is still more data in the expression:’comma(,)’

I have looked in the Book “Spring In Action”, and have looked at the Spring spEL Documentation on Springs website. I have also googled for a quite a bit. Unfortunately, most of the code examples are done in code and not on the spring definition files. Any assistance in this would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:59:18+00:00Added an answer on May 28, 2026 at 12:59 am

    In your example you are reading a “nameList” property as a String ( not as a java.util.List ). You would need to convert it to a list first:

    <bean id="listOfNames" class="org.springframework.util.StringUtils" factory-method="commaDelimitedListToSet">
        <constructor-arg type="java.lang.String" value="${nameList}"/>
    </bean>
    

    and then you can apply SPeL to it:

    <property name="mySingleName" value="#{listOfNames[0]}" />
    

    similar problem / solution here: Spring: Reading collections form property files

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using
Given this HTML: <div>foo</div><div>bar</div><div>baz</div> How do you make them display inline like this: foo
Given a (source) patch file, what's the easiest way to apply this patch on
I'm writing a program that uses File I/O to traverse through a directory given
I'm currently want to display a list of data using DataTables. And I want
I have an API (from third party java library) that looks like: public List<?>
Greetings, i got into the following problem: Given a file of the following structure:
Given the following inputs: (note: this is not a linked list, it's all one
Given a list of links, i.e. <ul> <li><a href=#>item 1</a></li> <li><a href=#>item 2</a></li> <li><a
i am struggling with the CSS of an unordered list which i want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.