请求与响应

1.团队多人开发,没人设置不同的请求路径,冲突问题如何解决——设置模块名作为请求路径前缀

stuController.java

package com.itheima.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("stu")
public class stuController {
    @RequestMapping("/save")
    @ResponseBody
    public String save(){
        System.out.println("stu save ...");
        return "";
    }
    @RequestMapping("/delete")
    @ResponseBody
    public String delete(){
        System.out.println("stu delete...");
        return "";
    }
}

userController.java

package com.itheima.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/save")
    @ResponseBody
    public String save(){
        System.out.println("user save....");
        return "{sdasd}";
    }
    @RequestMapping("/delete")
    @ResponseBody
    public String delete(){
        System.out.println("user delete....");
        return "";
    }
}

利用前缀名来区分访问路径

posted @ 2023-02-26 14:15  会秃头的小白  阅读(11)  评论(0编辑  收藏  举报