• SpringMVC----@RequestMapping__请求方式


    1.

    package com.yk.springmvc.handlers;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    
    @RequestMapping("/springmvc")
    @Controller
    public class SpringMVCTest {
        
        private static final String SUCCESS = "success";
        /**
         * 使用method属性指定请求方式
         * @return
         */
        @RequestMapping(value="/testMethod",method=RequestMethod.POST)
        public String testMethod(){
            System.out.println("SpringMVCTest.testMethod()");
            return SUCCESS;
        }
        
        @RequestMapping("/testRequestMapping")
        public String testRequestMapping(){
            System.out.println("SpringMVCTest.testRequestMapping()");
    //        return "success";    下面会有很多,所以定义一个常量
            return SUCCESS;
        }    
    }

    2.测试POST请求(默认是GET请求)

    <%@ 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>Insert title here</title>
    </head>
    <body>
        <!-- 测试post请求 -->
        <form action="springmvc/testMethod" method="POST">
            <input type="submit" value="submit测试POST请求"/>
        </form>
    
        <!-- <a href="springmvc/testMethod">TesttestMethod</a> -->
        <br />
        <br />
        <br />
        <a href="springmvc/testRequestMapping">Test--RequestMapping</a>
        <br />
        <br />
        <br />
        <a href="helloworld">Hello World</a>
    </body>
    </html>
  • 相关阅读:
    useMemo与useCallback
    setState同步异步场景
    useEffect与useLayoutEffect
    Xbatis:SpringBoot 数据管理框架
    Vue3 项目生产环境下如何部署到 Nginx ?
    Config:用户属性配置框架
    50万年薪程序员的面试题
    Spring Security Auth/Acl 实践指南
    工作后,你悟出什么职场道理?
    Json:Java对象和Json文本转换工具类
  • 原文地址:https://www.cnblogs.com/yikuan-919/p/9726427.html
Copyright © 2020-2023  润新知