zoukankan      html  css  js  c++  java
  • 007 @CookieValue绑定请求中的cookie

    1.介绍

      

    2.使用的cookie

      

    3.index.jsp

     1 <%@ page language="java" contentType="text/html; charset=utf-8"
     2     pageEncoding="utf-8"%>
     3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     4 <html>
     5 <head>
     6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     7 <title>Insert title here</title>
     8 </head>
     9 <body>
    10 
    11     测试cookie
    12     <br>
    13     <a href="helloworld5/">JSESSIONID</a>
    14     <br><br>
    15     
    16     测试请求头
    17     <br>
    18     <a href="helloworld4/">Accept-Language</a>
    19     <br><br>
    20     
    21     测试请求参数
    22     <br>
    23     <a href="helloworld3?username=cj&age=13">Test Rest Get</a>
    24     <br>
    25 </body>
    26 </html>

    4.controller

     1 package com.spring.it;
     2 
     3 import org.springframework.stereotype.Controller;
     4 import org.springframework.web.bind.annotation.CookieValue;
     5 import org.springframework.web.bind.annotation.RequestMapping;
     6 
     7 @Controller
     8 public class RequestParamControl {
     9     @RequestMapping("/helloworld5")
    10     public String hello(@CookieValue(value="JSESSIONID") String sessionId) 
    11     {
    12         System.out.println("JSESSIONID="+sessionId);
    13         return "success";
    14     }
    15 }

    5.效果

      

  • 相关阅读:
    ActiveMQ的用途
    HTTP 状态码的完整列表
    Linux中脚本运行错误(坏的解释器:没有那个文件或目录)
    Linux下ping: unknown host www.baidu.com的解决办法
    python中的collection
    Table里嵌套ASPXGridView
    致2015
    WPF学习之Binding(二)
    WPF学习之Binding(一)
    WPF UI布局(Layout)
  • 原文地址:https://www.cnblogs.com/juncaoit/p/8419745.html
Copyright © 2011-2022 走看看