zoukankan      html  css  js  c++  java
  • HTTP请求地址映射

    HTTP请求地址映射

    1编写UserController 类

    package com.xiang.lesson01.controller;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    
    @Controller
    @RequestMapping(value = "/user")
    public class UserController {
    
        @RequestMapping("/login")
        public String register(){
            return "user/login";
        }
    
    
        @RequestMapping(value = "/dologin/{userId}",method = RequestMethod.POST)
        public String  login(){
            return "/user/success";
        }
    
    }
    

    2编写 login.jsp 文件

    <%--
      Created by IntelliJ IDEA.
      User: Xiang
      Date: 2021/9/9
      Time: 11:31
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <html>
    <head>
        <title>Title</title>
    </head>
    
    <body>
    <div align="center">
        <form action="<%=request.getContextPath()%>/user/dologin/123" method="post">
            <table border="1">
                <tr>
                    <td>user</td>
                    <td>
                        <input type="text" name="user">
                    </td>
                </tr>
                <tr>
                    <td>pwd</td>
                    <input type="password" name="pwd">
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="submit">
                    </td>
                </tr>
            </table>
        </form>
    </div>
    
    </body>
    </html>
    
    

    3编写success.jsp 文件

    <%--
      Created by IntelliJ IDEA.
      User: Xiang
      Date: 2021/9/9
      Time: 15:39
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>Title</title>
    </head>
    <body>
    <h3>
      success
    </h3>
    </body>
    </html>
    

    4运行结果

  • 相关阅读:
    js/jsp常用记录(一)
    Oracle 存储过程的基本语法 及注意事项
    PL/SQL Developer使用技巧、快捷键
    Zookeeper的功能以及工作原理
    牛客网PAT练兵场-德才论
    牛客网PAT练习场-数素数
    牛客网PAT练兵场-D进制的A+B
    牛客网PAT练习场-个位数的统计
    牛客网PAT练习场-数字分类
    牛客网PAT练习场-A+B和C
  • 原文地址:https://www.cnblogs.com/d534/p/15248680.html
Copyright © 2011-2022 走看看