zoukankan      html  css  js  c++  java
  • Spring Boot—12URL映射


    package com.sample.smartmap.controller;
    
    import java.util.List;
    
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.http.MediaType;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    import com.sample.smartmap.entity.User;
    import com.sample.smartmap.service.UserService;
    /**
     * mvc url映射测试
     * @author lijiazhi
     *
     */
    @Controller
    @RequestMapping("/urlmapper")
    public class URLMapperController {
        
        @Autowired UserService userService;
        
    
        @RequestMapping(path="/user/all/*.json" ,method = RequestMethod.GET)
        @ResponseBody
        public   List<User> allUser() {
            return userService.allUser();
        }
        
        
        
        @RequestMapping(path="/user/{id}.json" ,method = RequestMethod.GET)
        @ResponseBody
        public   User getById( @PathVariable Long id) {
            return userService.getUserById(id);
        }
        
        @GetMapping(path = "/{userId}.json", produces = "application/json")
        @ResponseBody
        public   User getUserById( @PathVariable Long userId) {
            return userService.getUserById(userId);
        }
        
        @GetMapping(value="/consumes/test.json",consumes = "application/json" )
        @ResponseBody
        public   User forJson() {
          return userService.getUserById(1l);
        }
    
    }
  • 相关阅读:
    第八周总结和实验六
    第七周总结与实验五
    遍历目录中的所有文件和目录,并生成全路径
    python watchdog
    Offer_answer_with_SDP_rfc3264
    [转]UML八大误解
    leetcode周赛220
    Codeforces Round #690 (Div. 3)
    学习资料
    鱼眼图与六面图转换(python)
  • 原文地址:https://www.cnblogs.com/gispathfinder/p/8921228.html
Copyright © 2011-2022 走看看