How can I query in Request Param in Spring MVC like http://localhost:8075/healthcheck?format=short
OR http://localhost:8075/healthcheck?format=full
@RestController
public class HealthController implements ErrorController{
@GetMapping(value = "/healthcheck", produces = "application/json")
public HashMap<String, String> shorts(@RequestParam("format") String format1){
HashMap<String, String> maps
= new HashMap<String, String>();
if(format1.equals("short") ){
System.out.println("--short111--"+format1);
maps.put("status", "OK");
//return map;
} else if (format1.equals("full")) {
System.out.println("--Full111--"+format1);
SimpleDateFormat formatter = new SimpleDateFormat(
"yyyy-MM-dd 'T' HH:mm:ssZ");
Date date = new Date(System.currentTimeMillis());
String formattedString = formatter.format(date);
maps.put("currentTime", formattedString);
maps.put("status", "OK");
}
return maps;
}
@GetMapping(value = "/healthcheck", produces = "application/json")
public HashMap<String, String> full(@RequestParam(defaultValue="full") String format){
System.out.println("full");
HashMap<String, String> map
= new HashMap<String, String>();
SimpleDateFormat formatter = new SimpleDateFormat(
"yyyy-MM-dd 'T' HH:mm:ssZ");
Date date = new Date(System.currentTimeMillis());
String formattedString = formatter.format(date);
map.put("currentTime", formattedString);
map.put("status", "OK");
return map;
}
compare the param value format
for short or full