Announcement Announcement Module
Collapse
No announcement yet.
Force response content-type Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Force response content-type

    Hi,

    I'm generating svg charts dynamically and returning it from my controller. This is working perfectly except that it's not returning the correct ""image/svg+xml"" Content-Type in the header which is making some padding problems in the browser. I've tried to force it with setContentType or addheader but it's still returning "text/html".

    I've allready read about the "Accept" header thing but I really want to be able to force it manually.

    Here is the controller method that returns the svg :

    Code:
    @RequestMapping(value = "/company/{isin}/history", method = RequestMethod.GET)
    @ResponseBody
    public String getHistoryChart(Model model, @PathVariable String isin, HttpServletResponse response) {
    	String svg = companyModel.getHistoryChart(isin, new Dimension(700, 200));
    	//response.setContentType("image/svg+xml");
    	response.addHeader("Content-Type", "image/svg+xml");
    
    	return svg;
    }
    Thank you so much if someone could help me ... this is driving me crazy
Working...
X