@RequestMapping(value = "", method = RequestMethod.GET) @ResponseBody public List<WordDto> get(HttpServletRequest request) throws UnsupportedEncodingException { RequestHelper requestHelper = new RequestHelper(request); Map<String, String> params = requestHelper.getParams(); String sentence = params.get("sentence"); return segmentService.segment(sentence, params); }
@RequestMapping(value = "", method = RequestMethod.POST) public void post( @RequestBody String sentence, HttpServletRequest request, HttpServletResponse response) throws IOException { RequestHelper requestHelper = new RequestHelper(request); Map<String, String> params = requestHelper.getParams(); String contentType = request.getContentType(); String result = SegmentByContentType(sentence, params, contentType); response.setContentType("application/json; charset=utf-8"); PrintWriter writer = response.getWriter(); writer.append(result); }