• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Json array pass to model through controller [Spring Boot]

Posts: 1
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, How are you?
I have a web project, where I'm fetching a json file through JavaScript for frontend. It's working fine. But when I send those json data to my model, I'm not able to sent them.


and in my controller,

In model class.

So how can pass json value with variable from one form?
If you want to see my whole project, here is the link. Dropdown
Posts: 21972
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your models are expected to be a list / array of strings, but your JavaScript code sends them as a single string. From .val():

Get the current value of the first element in the set of matched elements or set the value of every matched element.

To get a list of values, you need to use map.

Untested (but copied from DevDocs):
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic