here's the MultiActionController
Successfully called the changeSimulationMode method but when it returns to browser... it will popup a download dialog to download the JSON content... like when downloading a file..Code:public class SimulationController extends MultiActionController { private SimulationService simulationService; /** * @param simulationService the simulationService to set */ @Autowired public void setSimulationService(SimulationService simulationService) { this.simulationService = simulationService; } public ModelAndView changeSimulationMode(HttpServletRequest request, HttpServletResponse response) throws Exception { Object objMode = request.getParameter("mode"); String strMode = (String) objMode; SimulationMode simulationMode = new SimulationMode(); simulationMode.setSimulationMode(strMode); simulationService.execChangeSimulationMode(simulationMode); String json = ""; try { json = "{" + "\"success\":true" + "}"; } catch (Exception e) { response.setHeader("Errored", "true"); response.setHeader("ErrorType", "system"); response.setHeader("ErrorMessage", e.getMessage()); json = "{success:false,errors:{reason:'error'}}"; } response.setContentType("text/json; charset=utf-8"); response.setHeader("Cache-Control", "no-cache"); PrintWriter pw = response.getWriter(); pw.write(json); pw.close(); return null; } }
I've heard that Spring MVC 2.5.6 and SWF2.0.8 provides JSON and XML view..
Could you guide me on how to implement the above..
thanks



Reply With Quote