10.26

发布时间 2023-12-18 20:26:10作者: 看海不为月

 对于controller包中的代码

复制代码
package com.itheima.controller;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RequestController {
//    @RequestMapping("simpleParam")
//    public String simpleParam(HttpServletRequest request)
//    {
//        String name=request.getParameter("name");
//        String ageStr=request.getParameter("age");
//        int age=Integer.parseInt(ageStr);
//        System.out.println(name+":"+age);
//            return "OK";
//    }

    @RequestMapping("simpleParam")
    public String simpleParam(String name,Integer age)
    {
        System.out.println(name+":"+age);
        return "OK";
    }
}
复制代码

启动springboot项目,在postman软件中监测