1、Entity
@Data
public class Card {
private StringimgLink;
private Stringtitle;
public Card(){
}
public Card(String imgLink,String title){
this.imgLink=imgLink;
this.title=title;
}
}
@Data
@Configuration
public class Shao {
private Stringavator;
private Stringwriter;
private Stringpic;
private Stringtitle;
private Stringcontent;
private Stringmpic;
private Stringmtitle;
private Stringmcontent;
}
2、DAO
@Configuration
@Data
public class CardDAO {
public ListgetCard(){
Card[] cards={
new Card("1.jpg","FD"),
new Card("1.jpg","FD"),
new Card("1.jpg","F"),
new Card("1.jpg","F"),
new Card("1.jpg","F"),
new Card("1.jpg","F"),
new Card("1.jpg","F"),
new Card("1.jpg","F"),
};
List cardList= Arrays.asList(cards);
return cardList;
}
public UsergetUser(){
User user=new User();
user.setName("123");
user.setAvatar("1.jpg");
return user;
}
}
3、Controller
@Controller
public class CardController {
@Resource
private CardDAOcardDAO;
@GetMapping("card")
public StringgetAll(ModelMap map){
List cardList=cardDAO.getCard();
User user=cardDAO.getUser();
map.addAttribute("cardList",cardList);
map.addAttribute("user",user);
return "card";
}
}
@Controller
public class ShaoController {
@Resource
private ListshaoList;
@GetMapping("shao")
public Stringshao(ModelMap map){
shaoList=new ArrayList<>();
Shao shao=new Shao();
shao.setAvator("https://cdn.sspai.com/attachment/origin/2015/01/15/215332.jpg?imageMogr2/quality/95/thumbnail/!80x80r/gravity/Center/crop/80x80");
shao.setWriter("洛世");
shao.setPic("https://cdn.sspai.com/2018/07/23/521dfa9b74e80cd38b6b1a6fbb1f2467.jpg?imageMogr2/quality/95/thumbnail/!360x220r/gravity/Center/crop/360x220");
shao.setTitle("简单三步");
shao.setContent("我们身边不少人习惯过农历生日,但是农历日期很难记住,其实iPhone自带了农历功能,这篇文章开始叫你如何开启隐藏的农历生日提醒");
shao.setMtitle("玩转workflow");
shao.setMpic("https://cdn.sspai.com/other/136_1490237571570.jpg?imageMogr2/quality/95/thumbnail/!828x442r/gravity/Center/crop/828x442");
shao.setMcontent("workflow是ios上一款被称为【效率神器】app");
Shao shao1=new Shao();
shao1.setAvator("https://cdn.sspai.com/attachment/origin/2017/02/01/365918.jpg?imageMogr2/quality/95/thumbnail/!80x80r/gravity/Center/crop/80x80");
shao1.setWriter("Navis");
shao1.setPic("https://cdn.sspai.com/2018/07/27/14f6df1cca005e5ecabddd3e47f9aaa2.jpg?imageMogr2/quality/95/thumbnail/!360x220r/gravity/Center/crop/360x220");
shao1.setTitle("福利派丨夹在显示器上的台灯,美观实用的完美照明解决方案:明基 ScreenBar Plus 屏幕挂灯");
shao1.setContent("明基 ScreenBar Plus 不仅提供了高素质的光源条件,还能根据环境光自动调整亮度,夹挂设计也解决了传统桌面台灯高度调节有限挡住屏幕的问题,我愿意把它称为多显示器 / 紧凑桌面空间的终极照明解决方案。");
shao1.setMpic("https://cdn.sspai.com/other/705956_1490770613690.jpg?imageMogr2/quality/95/thumbnail/!828x442r/gravity/Center/crop/828x442");
shao1.setMtitle("提升效率之路");
shao1.setMcontent("一个优秀的效率工具能让你在提升效率的路上事半功倍");
Shao shao2=new Shao();
shao2.setAvator("https://cdn.sspai.com/2018/07/20/178714f8312ff28c6e5cc743e1a145fd.jpg?imageMogr2/quality/95/thumbnail/!80x80r/gravity/Center/crop/80x80");
shao2.setWriter("大飞bigfly");
shao2.setPic("https://cdn.sspai.com/2018/07/15/17ef4fe0943f250dde344880ccdb5717.jpg?imageMogr2/quality/95/thumbnail/!360x220r/gravity/Center/crop/360x220");
shao2.setTitle("智能家居初体验 | 带你认识我家的赵狗剩、赵铁柱和赵小爱");
shao2.setContent("快到家时自动开启空调、定时关灯提醒自己睡觉、语音查快递……我打造了一套智能家居,在独居生活中享受自动化带来的便利。");
shao2.setMpic("https://cdn.sspai.com/other/718855_1493173455255.png?imageMogr2/quality/95/thumbnail/!828x442r/gravity/Center/crop/828x442");
shao2.setMtitle("装了啥?");
shao2.setMcontent("你的手机装了哪些常见的或小众app?");
shaoList.add(shao);
shaoList.add(shao1);
shaoList.add(shao2);
map.addAttribute("shaoList",shaoList);
return "shao";
}
}