Mini Project: Same Data as JSON or XML
Learn Mini Project: Same Data as JSON or XML (Content Negotiation, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Mini Real-Time Project: Same Data as JSON or XML Problem Partners ask for the same product data in different formats: browsers want JSON, an old system wants XML. Let the client choose with the Accept header or with a ?format= parameter, and refuse formats that are not supported. Requirements Return one object and let Spring choose JSON or XML. Enable the format parameter (?format=xml). Set JSON as the default when the client gives no preference. Show 406 Not Acceptable for an unsupported type. Use produces to offer one extra text format. Concepts Used content negotiation Accept header...