ARTICLE AD BOX
I recently joined a company project built using Spring Boot 2.x.
The project exposes REST APIs, but instead of modern annotations like:
@RestController @PostMappingthe code uses older style patterns like this:
@ResponseBody @RequestMapping(value = "/save", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<String> save(@RequestBody String input) { JSONObject response = new JSONObject(); try { JSONObject request = new JSONObject(input); if (request.isNull("name")) { return new ResponseEntity<>("Invalid input", HttpStatus.BAD_REQUEST); } JSONObject result = service.save(request); return new ResponseEntity<>(result.toString(), HttpStatus.OK); } catch (Exception e) { response.put("message", e.getMessage()); return new ResponseEntity<>(response.toString(), HttpStatus.UNAUTHORIZED); } }I understand modern Spring Boot reasonably well using DTOs and @RestController.
My questions are:
Is this still considered REST API architecture?
Is this style based on older Spring MVC patterns?
Why do some enterprise projects still use this style?
Is manual JSONObject parsing common in older projects?
What should I learn to understand and work effectively with this type of codebase?
Thanks!
