package com.agile.train;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class MainController {
    private static final Log log = LogFactory.getLog(MainController.class);

    @Value("${appKey}")
    private String appKey;

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String index(ModelMap model) throws Exception {
        log.debug("index start");
        model.put("message", "hello world");
        return "index";
    }

    @RequestMapping(value = "/search", method = RequestMethod.POST)
    public String result(HttpServletRequest request, ModelMap model) throws Exception {
        log.debug("result start");
        log.debug("searchKeyword:" + request.getParameter("searchKeyword"));
        return "index";
    }

    @RequestMapping(value = "/data", method = RequestMethod.GET)
    public
    @ResponseBody
    String data() throws Exception {
        JSONObject result = new JSONObject();
        result.put("message", "hello world");
        return result.toString();
    }

    @RequestMapping(value = "/property", method = RequestMethod.GET)
    public
    @ResponseBody
    String property() throws Exception {
        JSONObject result = new JSONObject();
        result.put("property", appKey);
        return result.toString();
    }
}

@@ -459,65 +459,79 @@
 n.Re
-sponseBody;%0A%0Aimport javax.servlet.http.HttpServletRequest
+questParam;%0Aimport org.springframework.web.bind.annotation.ResponseBody
 ;%0A%0A@
@@ -785,30 +785,16 @@
 g index(
-ModelMap model
 ) throws
@@ -825,21 +825,23 @@
 .debug(%22
-index
+welcome
  start%22)
@@ -846,53 +846,8 @@
 %22);%0A
-        model.put(%22message%22, %22hello world%22);%0A
     
@@ -970,34 +970,59 @@
 ult(
-HttpServletRequest request
+@RequestParam(%22searchKeyword%22) String searchKeyword
 , Mo
@@ -1073,22 +1073,22 @@
 .debug(%22
-result
+search
  start%22)
@@ -1130,45 +1130,57 @@
 %22 + 
-request.getParameter(%22searchKeyword%22)
+searchKeyword);%0A        log.debug(%22search finish%22
 );%0A 

make request parameter can easy get