package controller;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import model.Family;
import model.Music;
@Controller
public class PageController {
/**
* 默认主题
*
* @param model
* @param type
* @return
*/
@RequestMapping("/p/{type}")
public String findPage(Model model, @PathVariable("type") String type) {
this.buildListByType(model, type);
return "tiles/" + type;
}
/**
* 左侧菜单
*
* @param model
* @param type
* @return
*/
@RequestMapping("/p2/{type}")
public String findPage2(Model model, @PathVariable("type") String type) {
this.buildListByType(model, type);
return "tiles2/" + type;
}
/**
* 运行时构建视图(Runtime Composition)
* http://tiles.apache.org/framework/tutorial/advanced/runtime.html
* http://tiles.apache.org/framework/tutorial/advanced/el-support.html
*
* @param model
* @return
*/
@RequestMapping("/rt")
public String forRuntimeEl(Model model) {
model.addAttribute("runtimeTemplate", "/WEB-INF/views/layout/layout.jsp");
model.addAttribute("runtimeAttribute", "/WEB-INF/views/carousel.jsp");
return "forRuntimeEl";
}
/**
* 无关Tiles,配合springMVC配置中defaultViewResolver(多视图解析器配合)
*
* @param model
* @return
*/
@RequestMapping("/no-tiles")
public String noTiles(Model model) {
return "dont-starve-together";
}
/**
* 装填数据
*
* @param model
* @param type
*/
private void buildListByType(Model model, String type) {
type = StringUtils.hasLength(type) ? type : "home";
if ("home".equalsIgnoreCase(type)) {
List<Family> familys = new ArrayList<Family>();
familys.add(new Family("House Starks", "Winterfell", "Winter Is Coming"));
familys.add(new Family("House Baratheon", "Storm's End", "Ours Is The Fury"));
familys.add(new Family("House Lannister", "Casterly Rock", "Hear Me Roar"));
familys.add(new Family("House Targaryen", "King's Landing", "Fire and Blood"));
familys.add(new Family("House Tully", "Riverrun", "Family,Duty,Honor"));
familys.add(new Family("House Arryn", "Eyrie", "As High As Honor"));
familys.add(new Family("House Tyrell", "Highgarden", "Growing Strong"));
familys.add(new Family("House Martell", "Sunspear", "Unbowed,Unbent,Unbroken"));
model.addAttribute("familys", familys);
} else if ("music".equalsIgnoreCase(type)) {
List<Music> music = new ArrayList<Music>();
music.add(new Music("Make a Shadow", "Make a Shadow", "http://music.163.com/#/m/song?id=28283305"));
music.add(new Music("The Sandman", "Listen to your leader", "http://music.163.com/#/m/song?id=21301200"));
music.add(new Music("Little Talks", "Julia Sheer/Jon D.", "http://music.163.com/#/m/song?id=34040349"));
music.add(new Music("Wild Sea", "Roberto Cacciapaglia", "http://music.163.com/#/m/song?id=18495491"));
music.add(new Music("It's Time", "Imagine Dragons", "http://music.163.com/#/m/song?id=4128805"));
music.add(new Music("Show You", "SHawn Mendes", "http://music.163.com/#/m/song?id=28854177"));
model.addAttribute("music", music);
}
// 用于选择附加给哪个菜单active样式
model.addAttribute("activeNav", type);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Apache Tiles3整合SpringMvc
共56个文件
jsp:9个
xml:7个
css:6个
需积分: 9 8 下载量 197 浏览量
2017-12-15
10:55:57
上传
评论
收藏 3.48MB RAR 举报
温馨提示
Apache Tiles3整合SpringMvc Apache Tiles3整合SpringMvc
资源推荐
资源详情
资源评论
收起资源包目录
tiles3-springmvc.rar (56个子文件)
tiles3-springmvc
.project 1KB
src
main
webapp
WEB-INF
views
carousel.jsp 985B
music.jsp 783B
progressbar.jsp 469B
layout
nav2.jsp 2KB
layout.jsp 2KB
nav.jsp 2KB
layout2.jsp 2KB
home.jsp 800B
dont-starve-together.jsp 526B
config
tiles-advanced-features.xml 777B
spring-mvc-config.xml 2KB
tiles.xml 2KB
tlds
spring-form.tld 74KB
spring.tld 17KB
c.tld 16KB
fmt.tld 19KB
tiles.tld 35KB
web.xml 2KB
static
images
img3.jpg 1.33MB
img1.jpg 1.45MB
img2.jpg 458KB
js
npm.js 484B
bootstrap.js 67KB
bootstrap.min.js 36KB
fonts
glyphicons-halflings-regular.ttf 44KB
glyphicons-halflings-regular.woff2 18KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.svg 106KB
glyphicons-halflings-regular.woff 23KB
css
bootstrap-theme.css.map 47KB
bootstrap.min.css 120KB
layout2.css 2KB
bootstrap-theme.min.css 23KB
bootstrap-theme.css 26KB
bootstrap-combined.min.css 189KB
bootstrap.css.map 381KB
bootstrap.css 144KB
resources
log4j.xml 673B
log4j.dtd 5KB
java
model
Family.java 659B
Music.java 663B
controller
PageController.java 3KB
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 292B
org.eclipse.m2e.core.prefs 90B
org.eclipse.jdt.core.prefs 736B
org.eclipse.wst.common.project.facet.core.xml.bak 252B
org.eclipse.wst.validation.prefs 50B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs 117B
org.eclipse.core.resources.prefs 180B
org.eclipse.wst.common.component 689B
.jsdtscope 639B
pom.xml 4KB
.classpath 1KB
共 56 条
- 1
资源评论
指尖de柔情
- 粉丝: 314
- 资源: 81
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功