REST

2019-01-31  本文已影响0人  极客_Ls
动作 说明 示例
GET 获取资源 -/order/id
POST 新建资源 -/order
PUT 更新资源 -/order/id
DELETE 删除资源 -/order/id
@RequestMapping("/rest")
@Controller
public class RESTtest {
    //GET
    @RequestMapping("/GetTest/{id}")
    public String getSub(@PathVariable(value="id") Integer id) {
        System.out.println("get提交"+id);
        return "success";
    }
    //POST
    @RequestMapping(value="/PostTest",method=RequestMethod.POST)
    public String postSub() {
        System.out.println("post提交");
        return "success";
    }

}


<body>
    //get示例
    <a href="rest/GetTest/12">获取信息</a>
    //post示例
    <form method="post" action="rest/PostTest">
        <input value="POST" type="submit"/>
    </form>
</body>
</html>

浏览器form表单只支持get与post请求

上一篇 下一篇

猜你喜欢

热点阅读