• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What are the best way to GET Data from UI to the Web Controller in Java?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The possible ways are as below but need inputs on best practices as well some samples :
1) @RequestParam Map<String, String>
2) @RequestBody String
 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are those annotations from some framework you are using? If so then you need to find starter tutorials for that framework and read them including examples they have.
If you are using a framework then say which one so this thread gets moved to the right sub-forum (your question has nothing to do with Object Relational Mapping)
 
Virtual Pair Programmers Rep
Posts: 29
7
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like SpringMVC? If so it sounds like you should concentrate on using RequestParam for now:

eg



RequestBody is used for handling the entire request body, for example if you want to handle a PUT request sending something more complex than a parameter. An example of its use here: http://www.beabetterdeveloper.com/2013/07/spring-mvc-requestbody-and-responsebody.html
 
varun neema
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Richard and E Armitage for the inputs. Let me provide some more details -
I want to search for a Domain object name Contract with different parameters. For now I search for five parameters: FromDate, EndDate, Season, Name and Category. In future it should be possible to search for dynamic way of parameters. All the parameters are values of contract domain object.



I used this controller method


Season, Name, Category are dependencies of Contract. So for the jpa query I need the full Object of each. For this I want a dynamical way instead of writing similar code for all. But I'm quite sure that there is another and better solution. May be it is possible to do it with the contract object (domain and json) itstelf and also the jpa query.

Thanks for your inputs.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic