0

I am creating REST Api for a project using Spring MVC. On front end some reports are needed to be displayed in PDF, CSV and HTML format. Should I send JSON data to the front end for those reports and display the reports using some builtin plugins or doing it manually? Or should I send PDF,CSV and HTML files in response to the REST Api calls? I want maximum flexibility so what do you suggest?

Bilal Nasir
  • 65
  • 1
  • 7

1 Answers1

0

you should expose output in multiple output format(pdf, csv,html.. see ContentNegotiatingViewResolver in spring).

Depending on the requirement client can decide to call to any output and use it as required. In some use cases client may take raw data from rest and then convert; in some case it may take the refined output provided by rest.

sudmong
  • 2,036
  • 13
  • 12
  • Yes i am currently using ContentNegotiatingViewResolver. But if in future client may ask to send data in other format so I am thinking of returning raw data from REST call and on front end it can be converted to any format and custom templates can be used to represent it. – Bilal Nasir Apr 22 '13 at 09:46