Avatar of Rohit Bajaj
Rohit Bajaj
Flag for India

asked on 

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

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
JavaJava EE

Avatar of undefined
Last Comment
gurpsbassi

8/22/2022 - Mon