zoukankan      html  css  js  c++  java
  • springmvc

    代码:

    @ResponseBody
        @RequestMapping("/hello3/{hello}")
        public String hello3(@PathVariable String hello) {
            return hello;
        }

     代码:

    package com.logan.SpringBootDemo01.controller;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    @Controller
    public class MyController {
        
        @ResponseBody
        @RequestMapping("/hello")
        public String hello() {
            return "hello";
        }
        
        @ResponseBody
        @RequestMapping("/hello1")
        public String hello1() {
            return "hello1";
            
        }
        
        @ResponseBody
        @RequestMapping("/hello2")
        public String hello2() {
            return "hello2";
        }
        
        @ResponseBody
        @RequestMapping("/hello3/{hello}")
        public String hello3(@PathVariable String hello) {
            return hello;
        }
        
        @ResponseBody
        @RequestMapping("/hello4")
        //可以这样访问http://localhost:8080/hello4?type1=2&type=3
        public int hello4(@RequestParam int type) {
            return type;
        }
        
    
    }
  • 相关阅读:
    JSP第七次作业
    JSP第六次作业
    Jsp第五次作业
    软件测试第二次作业
    Jsp第四次作业2
    Jsp第四次作业1
    软件测试第一次作业
    JSP第三次作业
    JSP第二次作业
    第七次作业
  • 原文地址:https://www.cnblogs.com/LoganChen/p/13208741.html
Copyright © 2011-2022 走看看