zoukankan      html  css  js  c++  java
  • SpringMV---params and headers

      配置文件承接一二章

       params

        params:请求的参数
        params=value 表示请求过来的参数必须等于value
        params!=value 表示请求过来的参数必须不等于value
        {params = vlaue1 ,params !=value2 }也可以写成数组的形式。
      

       headers

        headers:请求头
        每个浏览器的请求头是不同的,所以我们可以通过请求头的不同来区分浏览器。

      index.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Hello World</title>
    </head>
    <body>
     
    
     <form action="springMVC/test4Param" method="get">
     <input type="text" name="username"/>
     <input type="text" name="age"/>
     <input type="submit" value="submit"/>
     </form>
     
    
    </body>
    </html>

    test.java

    package com.hdxy.domian;
    
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.servlet.ModelAndView;
    /**
     * @author 流年拓荒者
     *
     */
    @RequestMapping("springMVC")
    @Controller
    public class Test {
       final public String SUCCESS="loginSuccess";
       /*params:请求的参数
        params=value 表示请求过来的参数必须等于value
        params!=value 表示请求过来的参数必须不等于value
        {params = vlaue1 ,params !=value2 }也可以写成数组的形式。*/
       @RequestMapping(value="test4Param",params={"username","age!=10"})
        public String test4Param(){
            System.out.println("test4Param");
            return SUCCESS;
        }
    }
    流年拓荒者
  • 相关阅读:
    设置SSH编码为中文
    深入浅出REST架构 REST架构概述
    RESTful Web Services初探
    Linux 基础命令
    Linux 目录和文件操作
    Linux 压缩文件的命令行总结
    Linxu 监控命令总结
    Linux 下Tomcat的启动、关闭、杀死进程
    Linux日知录(常用问题笔记)
    linux 下远程连接mysql命令详解
  • 原文地址:https://www.cnblogs.com/lnthz/p/7865511.html
Copyright © 2011-2022 走看看