https://blog.youkuaiyun.com/qq_35246620/article/details/59620858
在构建spring boot项目的时候看到了这个代码段,
package cn.jerry.blog;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.Map;
@Controller
public class HelloWorld {
@RequestMapping("/hello")//表示该类的所有响应请求方法都是以该地址作为父路径
@ResponseBody
public Map<String, Object> hello() {
Map<String, Object> map = new HashMap<>();
map.put("hello", "world");
return map;
}
}
了解一下@ResponseBody与@Requestbody区别。
@RequestMapping的作用是处理请求地址映射