<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<a href="anno/testRequestHeader">RequestHeader</a>
</body>
</html>
package com.learn.controller;
import com.learn.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.support.SessionStatus;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.Map;
/**
* 常用的注解
*/
@Controller
@RequestMapping("/anno")
public class AnnoController {
/**
* 获取请求头的值
* @param header
* @return
*/
@RequestMapping(value="/testRequestHeader")
public String testRequestHeader(@RequestHeader(value="Accept") String header, HttpServletRequest request,HttpServletResponse response) throws IOException {
System.out.println("执行了...");
System.out.println(header);
// return "success";
// response.sendRedirect(request.getContextPath()+"/anno/testCookieValue");
return "redirect:/param.jsp";
}
}