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

  • SEARCH
  • Home
  • 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 8227337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:05:49+00:00 2026-06-07T16:05:49+00:00

This should be very basic but I can’t find anything about it in the

  • 0

This should be very basic but I can’t find anything about it in the web, just bits and pieces that I don’t seem able to fit together..

We’re using Spring MVC with freemarker. Now I want to add a form to my page that allows me to select a value from a predefined list (requires database access in the backend).

My controller:

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public ModelAndView get(@PathVariable Integer id) {

    // stuff..
    ModelAndView mav = new ModelAndView();

    mav.addObject("targetObject", new TargetObject());
    mav.addObject("options", Arrays.asList("a", "b", "c"));
    mav.setViewName("someview");

    return mav;
}

I found freemarkers spring support spring.ftl and it seems I should use <@spring.formSingleSelect> which I’ve tried like this:

someView.ftl:

<#import "../spring.ftl" as spring />

<form action="somePath" method="POST">
    <@spring.formSingleSelect "targetObject.type", "options", " " />
    <input type="submit" value="submit"/>
</form>

So targetObject.type is bound automatically by the macro it seems.

But how do I get my options into a freemarker seequence so that the macro can create the options?

Right now I get:

Expected collection or sequence. options evaluated instead to freemarker.template.SimpleScalar on line 227, column 20 in spring.ftl.
The problematic instruction:
----------
==> list options as value [on line 227, column 13 in spring.ftl]
 in user-directive spring.formSingleSelect [on line 53, column 9 in productBase/show.ftl]
----------

I also tried:

<@spring.bind "${options}" />

and more things along those lines but with no success:

freemarker.core.NonStringException: Error on line 48, column 18 in someView.ftl
Expecting a string, date or number here, Expression options is instead a freemarker.template.SimpleSequence

Thank’s for any help!

  • 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-06-07T16:05:51+00:00Added an answer on June 7, 2026 at 4:05 pm

    After much rephrasing and rethinking I finally discovered the solution:

    First

    I need to have a bean hold my choice obviously

    Second

    The options need to be initialized as a String list and provided by Spring MVC to the page:

    public ModelAndView get() {
    
        // ...
        ModelAndView mav = new ModelAndView();
        List<String> options = Arrays.asList(getOptionsFromDatabaseAndConvertToStringList());
        mav.addObject("options",options );
        mav.setViewName("someview");
    
        return mav;
    }
    

    Third

    options now need to be bound in the freemarker template and can then be accessed like any other freemarker variable (i.e. NO quotation marks):

    <@spring.bind "options" />
    
    <form action="whatever" method="POST">
        <@spring.formSingleSelect "targetBean.choice", options, " " />
        <input type="submit" value="submit"/>
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This should be a very basic design question, but for some reason it doesn't
This seems like it should be very simple but I can't get it to
This should be very basic, but I am a little stumped! Here is my
I am aware that this is a very basic question, but an interviewer asked
This should be very simple, but I'm blocking on this.... Let's say, for the
This should be very easy but I don't know how to do it. I
I feel as if this should be very simple, but it's behaving strangely. I
This should be simple, but I am still lost. There is a very similar
This should be simple. I'm making a very basic app, based on the Utility
I'm just learning wcf and can't understand one very basic thing. I'm creating a

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.