Solved

Wether to keep url params in method parameters or fetch it inside the method

Posted on 2016-08-11
4
40 Views
Last Modified: 2016-08-13
HI,
I have a function like :
 
@RequestMapping(value = "")
    public ModelAndView newNote(@RequestParam(value = "noteEvent", required = false) String noteEvent, HttpServletResponse response, HttpServletRequest request) throws IOException {
        String token = request.getParameter("token");

Open in new window

The noteEvent is actually a json param like : { "name":"sdfsdf","button":"sdfds","userId":"u:guid1","sdfdf":"sdfds","chat":"u:sdf","chatName":"Ben sdf"}

1) Once approach is i put everything in the params... Like here i am accessing request.getParameter("token")
which i could move to method params.. But somtimes i have noticed the function param list gets too large.

2) Other approach is to not put anything in params and access everything inside.

3) Or mix match

Need views from experts. What approach you follow and when ...Whats best to do ?

Thanks
0
Comment
Question by:Rohit Bajaj
  • 2
4 Comments
 
LVL 15

Expert Comment

by:gurpsbassi
ID: 41753606
Is this a GET request?
0
 

Author Comment

by:Rohit Bajaj
ID: 41753641
yes this is a get request
0
 
LVL 35

Accepted Solution

by:
mccarl earned 400 total points
ID: 41753679
Personally, I would probably just put them all as method parameters, but I don't have much of a problem with methods that have numerous parameters, I know some people do though.

The other possibility that I might consider, if you have some params that are required and some that are optional, is to leave the required ones in the method and attempt to retrieve the optional ones if/when needed.
0
 
LVL 15

Assisted Solution

by:gurpsbassi
gurpsbassi earned 100 total points
ID: 41754138
if you were to flatten that JSON object into request params, it wouldn't be so bas as mccarl suggested. Its only a handful.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
stringclean challenge 26 58
computer science syllabus 3 53
wordmultiple challenge 12 93
Java and GPO 11 47
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now