package com.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Date;

@Controller
// restful风格接口测试
public class RestfulController {
    //http://localhost:8083/rest1/zxy/19
    @RequestMapping("/rest1/{name}/{age}")
    @ResponseBody
    public void rest1 (@PathVariable(value = "name") String name,
                       @PathVariable(value = "age") Integer age) {
        System.out.println(name);
    }
    // http://localhost:8083/rest2?date=2019-12-01
    @RequestMapping("/rest2")
    @ResponseBody
    public void rest1 (@RequestParam(name = "date") Date date, HttpSession session) {
        System.out.println(date);
        System.out.println(session);
    }
    @RequestMapping("/rest3")
    @ResponseBody
    public void rest3 (@RequestHeader(value = "User-Agent") String userAgent) {
        System.out.println(userAgent);
    }
    @RequestMapping("/rest4")
    @ResponseBody
    public void rest4 (@CookieValue(value = "JSESSIONID") String sessionId) {
        System.out.println(sessionId);
    }

}
