Spring Boot—12URL映射
2024-09-23 05:20:06
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);
} }
最新文章
- 《C#并发编程经典实例》笔记
- LeakCanary Android 和 Java 内存泄露检测。
- SQL注入的原理以及危害
- nios II--实验3——led 100M硬件部分
- nginx安装ssl
- Linq二 LinqToSql
- 《Java程序性能优化》学习笔记 JVM和并发优化
- 记redis的一个测试
- Android本地JUnit Text
- Secure CRT 如何连接虚拟机里面的CentOS系统 当主机没有网的时候 作者原创 欢迎转载
- php Debugging with Xdebug and Sublime Text 3(转)
- unity3D:游戏分解之曲线
- centos系统查看系统版本、内核版本、系统位数、cpu个数、核心数、线程数
- 解决ios10以上H5页面手势、双击缩放问题
- 3.1.4 Spring的事务管理
- SpringMVC(十三) RequestMapping 使用servlet原生API作为参数
- 9.5 翻译系列:数据注解之ForeignKey特性【EF 6 Code-First系列】
- 一个Interface 继承多个Interface 的总结
- iOS10.0 &; Swift 3.0 对于升级项目的建议
- [报错] Xcode Error-Could not insert new outlet connection: Could not find any information for the class named ";xxx";
热门文章
- Python小白学习之路(十三)—【递归调用】
- 初始化css文件
- c++类定义和类实现
- “context:include-filter”与“context:exclude-filter”标签作用解释
- 监督学习&mdash;&mdash;决策树理论与实践(上):分类决策树
- Karatsuba乘法--实现大数相乘
- python获取动态网站上面的动态加载的数据(selenium+Firefox)
- C/C++ -- Gui编程 -- Qt库的使用 -- 使用自定义类
- tensorflow summary
- PyCharm2018专业版激活步骤