• 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 ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How to acces json data that was passed as a parameter inside a Spring MVC Controller  RSS feed

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following script that retrieves two id's and creates a json string with those two id's and send them to a Spring MVC controller, but i dont know how to acces those values inside my controller i was thinking in using string split functions but since i'm using jackson i thing that there should be already created methods to do this.

here is my script:




that scripts send to ints inside a json those two ints are the ids of a role object and a perm object

and here is my controller method



my json variable have the ids that i need, but i dont know how to get them is there a ObjectMapper Jackson method that i could use to split the string to get the values i need.
 
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you try this?

 
Jhon Parker
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mohamed Sanaulla wrote:Can you try this?



i already did it but i need to cast some values from string to int i would like a way to do it without having to do that cast

here is my controller now



that work, but i would like to do it without having to cast the values from string to int
 
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If casting is to be avoided, my best bet is a custom object instead of the String as an @RequestBody argument
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!