Required String parameter is not present Spring MVC

LeTadas picture LeTadas · Sep 20, 2016 · Viewed 54.1k times · Source

I want to access two different pages in my browser using:

http://localhost:8080/name?views

and

http://localhost:8080/name?uviews

But I'm getting error Required String parameter 'uviews' is not present when I use first url and I get Required String parameter 'views' is not present when I use second one.

here is my Response body

@ResponseBody     
public Object getViewInJson(@RequestParam("views") String views ,@RequestParam("uviews") String uviews) throws IOException{

 loader = new AnalyticsLoader();



    return loader.AnalyticsLoader(views,uviews);
}

How can access both views and uviews?

Answer

Prasanna Kumar H A picture Prasanna Kumar H A · Sep 20, 2016

Add required=false attribute to @RequestParam..Change to

@RequestParam(required=false,name="views") String view,..