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 8874733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:47:49+00:00 2026-06-14T18:47:49+00:00

I am trying to build a javascript object to submit a form. One property

  • 0

I am trying to build a javascript object to submit a form. One property must be an array of ids, see below:

var customPostData = {
    lecturer:$("#modulesessform").serializeArray()[0].value,
    topic:$("#topic").val(),
    sessionType:$("#sessionType").val(),
    sessionDate:$("#sessionDate").val(),
    startTime:$("#startTime").val(),
    endTime:$("#endTime").val(),
    sessionStatus:$("#sessstatus").val(),
    attendedstudents:studentsattended.toSource()                                                                           
};

Here is what that looks like in the post data.

attendedstudents    ["7348", "6472", "7392", "7235", "7399", "6943"]
endTime 8:30 PM
lecturer    5582
sessionDate Tuesday, October 02, 2012
sessionStatus   Completed
sessionType 1
startTime   5:30 PM
topic   bla

The problem is the last field. I want to be able to say attendedstudents[]:studentsattended.toSource.
You see I am using spring MVC and in order to tell it that this parameter is a collection of some kind I need the [ ] as part of the name-value pair. Here is a small snippet:

public @ResponseBody String ajaxcreate( @PathVariable("si") Long si,
                                        @RequestParam("sessionDate") @org.springframework.format.annotation.DateTimeFormat(pattern = "EEEE, MMMM dd, yyyy") java.util.Calendar sessionDate,
                                        @RequestParam("startTime") @org.springframework.format.annotation.DateTimeFormat(pattern = "hh:mm a") java.util.Calendar startTime,
                                        @RequestParam("endTime") @org.springframework.format.annotation.DateTimeFormat(pattern = "hh:mm a") java.util.Calendar endTime,
                                        @RequestParam("attendedstudents[]") ArrayList<Long> attendedstudents,
                                        Model uiModel, HttpServletRequest httpServletRequest) {//bla bla bla}

See the very last @RequestParam. I tried it without the square brackets in spring, but that throws errors. I also tried using an array of strings and parse the string as a long, see below.

 @RequestParam("attendedstudents") String[] attendedstudents

This produced this exception. Apparently, it’s trying to parse the square bracket as part of the string.

For input string: “[“7348″”
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
java.lang.Long.parseLong(Long.java:410)
java.lang.Long.valueOf(Long.java:525)**

  • 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-14T18:47:50+00:00Added an answer on June 14, 2026 at 6:47 pm

    Enclose it in Quotes

    'attendedstudents[]' :
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build an array/object based on user-input to a form that has
I'm somewhat new to object oriented programming in Javascript and I'm trying to build
I'm trying to understand how to build a JSON object in JavaScript. This JSON
I'm trying to build up a string array in JavaScript and get the results
I've been trying to see if I can build my JavaScript objects as intuitively
I'm trying to build modal windows on the fly from single javascript object passed
This is partially a javascript technique question. I am trying to build an object
I trying to build a JavaScript function which will grab a JSON encoded array
I'm trying to build the c# approximation of a JavaScript object literal to be
I'm trying to build an object in javascript using self-invoking functions to set the

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.