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);
        }
    
    }
  • 相关阅读:
    手机获取ip地址
    CoreGraphics 自定义button
    抽奖及背景图片的透明度设置时连着转盘图片也跟着虚幻解决方法
    多个UIcollctionView,返回个数不对错误
    collectionview item 间距
    判断键盘的高度
    orcle 11g 的安装图解
    clone()详解
    isAssignableFrom ,isInstance , Instanceof() 区别
    三元表达式
  • 原文地址:https://www.cnblogs.com/gispathfinder/p/8921228.html
Copyright © 2011-2022 走看看