Report plug-in Echart
Java class
Package com. spring. controller; import java. io. IOException; import java. util. arrays; import java. util. date; import java. util. list; import javax. servlet. http. httpServletRequest; import javax. servlet. http. httpServletResponse; import net. sf. json. JSONArray; import org. springframework. stereotype. controller; import org. springframework. web. bind. annotation. requestMapping; import org. springframework. web. bind. annotation. requestMethod; import org. springframework. web. servlet. modelAndView; @ Controllerpublic class EchartController {/*** static Echart report page */@ RequestMapping (value = "user/echart", method = {RequestMethod. POST, RequestMethod. GET}) public ModelAndView PostJsonTest (HttpServletRequest request, HttpServletResponse response) throws IOException {ModelAndView mav = new ModelAndView (); mav. addObject ("time", new Date (); mav. setViewName ("echart/echart"); return mav;}/*** dynamic Echart report page */@ RequestMapping (value = "user/echart2", method = {RequestMethod. POST, RequestMethod. GET}) public ModelAndView dynamicEchart (HttpServletRequest request, HttpServletResponse response) throws IOException {ModelAndView mav = new ModelAndView (); String str [] = {"shirt 2", "sweater 2 ", "chiffon shirt 2", "pants 2", "high heels 2", "so 2", "nickname"}; float bar [] = {15, 28, 41, 45, 56,120, 89 }; List <String> category = Arrays. asList (str); // converts an array to listmav. addObject ("time", new Date (); mav. addObject ("listData", category); // listmav. addObject ("array", str); // array mav. addObject ("jsonArray", JSONArray. fromObject (str); // convert to a json array mav. addObject ("jsonList", JSONArray. fromObject (category); // convert to a json array mav. addObject ("jsonInt", JSONArray. fromObject (bar); // convert to a json array mav. setViewName ("echart/dynamicEchart"); return mav ;}}
Static Page:
<% @ Page language = "java" import = "java. util. * "pageEncoding =" UTF-8 "%> <% String path = request. getContextPath (); String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/"; %> <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
Dynamic page:
<% @ Page language = "java" import = "java. util. * "pageEncoding =" UTF-8 "%> <% String path = request. getContextPath (); String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/"; %> <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
Run: