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);
        }
    
    }
  • 相关阅读:
    javascript
    javascript
    javascript
    easyui datagrid checkbox multiple columns have been done do
    combogrid获取多个字段的方法
    jquery显示、隐藏div的方法
    纠正jQuery获取radio选中值的写法
    comgrid获取多选值
    xheditor
    java向图片上写字,两个图片合并的方法
  • 原文地址:https://www.cnblogs.com/gispathfinder/p/8921228.html
Copyright © 2011-2022 走看看