首页 > 编程语言 > 详细

Spring Boot学习笔记

时间:2016-03-23 06:05:39      阅读:184      评论:0      收藏:0      [点我收藏+]

例子1:   http://spring.io/guides/gs/rest-service/

字符串填充,如%s

private static final String template = "Hello, %s!";
String name = "wwj";
String.format(template, name);

自增类型

private final AtomicLong counter = new AtomicLong();
counter.incrementAndGet();

@RequestMapping  @RequestParam

@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(value="name", defaultValue="World"){...}

例子2:   http://spring.io/guides/gs/scheduling-tasks/

按格式输出时间

private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
dateFormat.format(new Date());

@Scheduled  定时运行

@Scheduled(fixedRate = 5000);     //加在一个小函数前面?
@EnableScheduling //加在程序主入口前面

例子3:  http://spring.io/guides/gs/device-detection/

@ResponseBody 转为HTTP返回

public @ResponseBody String detectDevice(Device device) {
    ...
    return "Hello " + deviceType + " browser!";
}

设备类型判断

import org.springframework.mobile.device.Device;
Device device;
device.isNormal();
device.isMobile();
device.isTablet();

 

Spring Boot学习笔记

原文:http://www.cnblogs.com/wwjyt/p/5309441.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!