ssm框架下 tiles框架 的使用

前些天發現了一個巨牛的人工智能學習網站,通俗易懂,風趣幽默,忍不住分享一下給大家。點擊跳轉到教程。

tiles框架的工作 在springMVC工作流程中屬于視圖解析器 解析視圖這一步。算是視圖解析器的一個插件,作了視圖解析這步的一部分工作。

?

1. ?加maven依賴引入 jar包:

?

                <!-- 頁面布局 --><dependency><groupId>org.apache.tiles</groupId><artifactId>tiles-jsp</artifactId><version>3.0.5</version></dependency>

?

?

?

2. 在 spring-servlet.xml 中加入配置:

?

<!-- tiles 標簽  --><bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"><property name="definitions"><list><value>/WEB-INF/tiles/tiles-definitions.xml</value></list></property></bean>


3. 書寫如配置中取名的?tiles-definitions.xml 文件,并放到對應的?/WEB-INF/tiles/ ?目錄下:

?

?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN" "http://tiles.apache.org/dtds/tiles-config_3_0.dtd"> <tiles-definitions> <!-- Default 主布局 --> <definition name="defaultTemplate" template="/WEB-INF/jsps/common/layout.jsp"> <put-attribute name="title" value="布局頁" type="string" /></definition> 
</tiles-definitions>


4. layout.jsp就是主布局頁面,可以把公用的js、css的引用寫在這個頁面,子頁面就不用再重復引入了。

?

我的布局是左側為導航頁面,右側為每個功能頁面。

在對應位置書寫layout.jsp 頁面:

?

<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<% String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>"/>  
<title><tiles:insertAttribute name="title" /></title>  <!-- 主布局頁面 --><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><!-- Bootstrap -->
<link href="css/bootstrap/css/bootstrap.min.css" rel="stylesheet"><!-- 引入自定義的樣式等內容 -->
<tiles:insertAttribute name="heads" />
</head><body class="nav-md"><div class="container body" ><div class="main_container"><!-- 功能菜單界面 --><jsp:include page="nav.jsp"></jsp:include><!-- /功能菜單界面 --><!-- 當前頁面內容 --><div class="right_col" role="main"><tiles:insertAttribute name="body" /></div><!-- /當前頁面內容 --></div></div><!-- jQuery -->
<script charset="utf-8" src="js/jquery.min.js"></script>
<!-- Bootstrap -->
<script charset="utf-8" src="js/bootstrap.min.js"></script><tiles:insertAttribute name="scripts" />
</body>
</html><!-- 主布局頁面 --><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><!-- Bootstrap -->
<link href="css/bootstrap/css/bootstrap.min.css" rel="stylesheet"><!-- 引入自定義的樣式等內容 -->
<tiles:insertAttribute name="heads" />
</head><body class="nav-md"><div class="container body" ><div class="main_container"><!-- 功能菜單界面 --><jsp:include page="nav.jsp"></jsp:include><!-- /功能菜單界面 --><!-- 當前頁面內容 --><div class="right_col" role="main"><tiles:insertAttribute name="body" /></div><!-- /當前頁面內容 --></div></div><!-- jQuery -->
<script charset="utf-8" src="js/jquery.min.js"></script>
<!-- Bootstrap -->
<script charset="utf-8" src="js/bootstrap.min.js"></script><tiles:insertAttribute name="scripts" />
</body>
</html>


5. 導航頁面nav.jsp書寫 ?:

?

?

<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<% String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<base href="<%=basePath%>"/>  <!-- 導航頁面 --><div class="col-md-3 left_col"><div class="left_col scroll-view"><div class="navbar nav_title" style="border: 0;"><a href="/" class="site_title"><i class="fa fa-paw"></i><span>小熊樂園 V0.1</span></a></div><div class="clearfix"></div><!-- 登錄人員信息 --><div class="profile"><div class="profile_pic"><img src="images/img.jpg" alt="..." class="img-circle profile_img"></div><div class="profile_info"><span>歡迎您:</span><h2><shiro:principal property="account"/></h2></div></div><br /><!-- 系統功能菜單 --><div id="sidebar-menu" class="main_menu_side hidden-print main_menu"><div class="menu_section"><h3><shiro:principal property="roleDesc"/></h3><ul class="nav side-menu"><shiro:hasPermission name="love:menu"><li><a><i class="fa fa-male"></i>完美生活<span class="fa fa-chevron-down"></span></a><ul class="nav child_menu"><shiro:hasPermission name="love:list"><li><a href="/loveList">愛的告白</a></li><li><a href="/feeling">心情印記</a></li></shiro:hasPermission></ul></shiro:hasPermission><shiro:hasPermission name="ad:menu"><li><a><i class="fa fa-bullhorn"></i>淺淺人生<span class="fa fa-chevron-down"></span></a><ul class="nav child_menu"><shiro:hasPermission name="adFlow:list"><li><a href="/adLife">默默心語</a></li></shiro:hasPermission></ul></li></shiro:hasPermission><shiro:hasPermission name="system:menu"><li><a><i class="fa fa-cog"></i>系統管理<span class="fa fa-chevron-down"></span></a><ul class="nav child_menu"><shiro:hasPermission name="systemAuth:menu"><li><a>系統權限<span class="fa fa-chevron-down"></span></a><ul class="nav child_menu"><shiro:hasPermission name="systemAuthRes:list"><li class="sub_menu"><a href="/systemAuthRes">權限資源</a></li></shiro:hasPermission><shiro:hasPermission name="systemAuthRole:list"><li class="sub_menu"><a href="/systemAuthRole">權限角色</a></li></shiro:hasPermission></ul></li></shiro:hasPermission><shiro:hasPermission name="systemAdmin:list"><li><a href="/systemAdmin">管理人員</a></li></shiro:hasPermission></ul></li></shiro:hasPermission></ul></div></div><!-- /menu footer buttons --><div class="sidebar-footer hidden-small">			<!-- /logout :退出功能訪問路徑是在spring-shiro.xml中配置的,由shiro執行 ,不走controller --><a data-toggle="tooltip" data-placement="top" title="退出" href="/logout"><span class="glyphicon glyphicon-off" aria-hidden="true"></span></a></div><!-- /menu footer buttons --></div>
</div><!-- jQuery -->
<script charset="utf-8" src="js/jquery.min.js"></script>省略...
<script type="text/javascript">
</script>	省略...
<script type="text/javascript">
</script>


6. 功能頁面書寫:

?

?

<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<% String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<base href="<%=basePath%>"/>  <tiles:insertDefinition name="defaultTemplate"><tiles:putAttribute name="title" value="心情印記時光軸" /><tiles:putAttribute name="heads"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>時光軸</title><style>
/* 			*{margin:0;padding:0} */.box{width:960px;height:300px;margin:100px auto;position:relative;z-index:1;} body{font-size:14px;font-family:"微軟雅黑"; background-attachment:fixed;z-index:0;}.box{margin:1px auto;position:relative;z-index:1;}/*內容發布區域*/.box .boxcenter{width:500px;height:200px;background:#4e8f86;position:absolute;top:80px;left:180px;border:1px solid green;border-radius:6px;}.box .boxcenter .boxc_t{height:30px;line-height:30px;color:gold;}.box .boxcenter .boxc_c{width:460px;height:100px;border:1px solid #A6C8FF;margin:8px auto;text-indent:10px;box-shadow:0 0 4px #A6C8FF;}.box .boxcenter .boxc_b{width:80px;height:30px;position:absolute;right:10px;bottom:8px;}.box .boxcenter .boxc_b a{font-size:14px;color:#fff;line-height:30px;background:#3bbfb4;border-radius:6px;display:block;text-align:center;text-decoration:none;}.box .boxcenter .boxc_b a:hover{background:#2C8E86;}.box .timeline{width:60px;height:100%;position:absolute;top:100px;left:80px;border-right:3px solid yellow;}.timeline .timeline_t{width:50px;height:50px;border-radius:50%;border:2px solid white;background:url("images/day_yuan.gif") no-repeat;background-size:100%;}.timeline .nextbox{width:380px;height:80px;position:absolute;top:260px;left:60px;}.a{width:380px;height:80px;background:#4e8f86;border-radius:6px;margin-top:30px;font-size:16px;line-height:20px;text-indent:20px;word-break:break-all;position:relative;left:6px;}.a .b{width:6px;height:6px;border-radius:50%;border:2px solid #fff;background:#9DCFE1;position:absolute;top:35px;left:-10px;}#time{font-size:20px;color:gold;}#hour{font-size:12px;color:gold;}</style></tiles:putAttribute><tiles:putAttribute name="body"><div class="box" style="width:100%;height:100%;background-image: url(images/record_back.jpg);"><!--內容發布區域--><div class="boxcenter" ><div class="boxc_t"><h4>???隨便說點什么吧...</h4></div><div class="boxc_c" contenteditable="true" id="aa" style="color:black;font-size:19px;"></div><div class="boxc_b"><a>發布</a></div></div><!--時光軸線--><div class="timeline"><div class="timeline_t"></div><div class="nextbox" style="color:black;font-size:19px;"></div></div></div></tiles:putAttribute><tiles:putAttribute name="scripts"><script type="text/javascript" src="js/jquery-1.11.2.min.js"></script><script type="text/javascript">	$(function(){$(".box").find(".boxc_b").click(function(){var center = $(".boxc_c").text();//.appendTo("nextbox");if(center==""){alert("嘻嘻,請寫下你此時的心情吧...");return;}$(".nextbox").prepend("<div class='a'>"+"<div class='b'></div>"+"<br/>"+"<span id='time'>??"+year+"-"+month+"-"+day+"??"+"<span id='hour'>"+hour+":"+min+"</span>"+"</span>"+"<br>"+"<p style='padding:4px'>"+center+"</p>"+"</div>");$(".boxc_c").text("");	});//alert(1);$(".boxc_c").keydown(function(event){					var len =$(".boxc_c").text().length;			if(len > 70){alert("夠了,別寫了,哪兒那么多話啊...");					}});var dateDom = new Date();//獲取本地時間,年月日時分var year = dateDom.getFullYear();var month = dateDom.getMonth()+1;var day = dateDom.getDate();var hour = dateDom.getHours();var min = dateDom.getMinutes();});</script></tiles:putAttribute>
</tiles:insertDefinition>

?

?

?

?

?

?

?

?

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/451904.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/451904.shtml
英文地址,請注明出處:http://en.pswp.cn/news/451904.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

數據結構與算法--7.樹的基礎知識

文章目錄一. 樹的概念二. 樹的術語三. 樹的種類四. 樹的存儲和表示五. 常見的樹的應用場景一. 樹的概念 二. 樹的術語 三. 樹的種類 四. 樹的存儲和表示 五. 常見的樹的應用場景

運用java 多線程模擬火車售票。。。。

public class Demo01 { public static void main(String[] args) { // TODO Auto-generated method stub //多線程并行時&#xff0c;會出現的問題 //同步&#xff1a; //買火車票&#xff0c;四個窗口A,B,C,D //創建任務 TicketTask task new TicketTask(); //四個窗口A,B,C,…

JQuery validate 各項驗證規則講解

前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到教程。 使用樣例見&#xff1a;http://blog.csdn.net/jiangyu1013/article/details/56014730 //定義中文消息 var cnmsg { required: “必選字…

數據結構與算法--8.二叉樹的基礎知識

文章目錄一. 二叉樹基本概念二. 二叉樹的性質三. 二叉樹的代碼實現四. 二叉樹的先序、中序、后序遍歷一. 二叉樹基本概念 二. 二叉樹的性質 三. 二叉樹的代碼實現 class Node(object):"""二叉樹節點"""def __init__(self,item):self.elem item…

ZooKeeper(二)ZooKeeper能做什么?

上一節介紹了ZooKeeper的一些基礎知識&#xff0c;這一節主要講ZooKeeper有哪些用途。命名服務&#xff08;Name Service&#xff09; 主要是作為分布式命名服務&#xff0c;通過調用zk的create node api&#xff0c;能夠很容易創建一個全局唯一的path&#xff0c;這個path就可…

jquery vilidate 使用小例

前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到教程。 // 修改$("#updForm").validate({submitHandler:function(form){new $.flavr({ content : 是否確認修改管理員?,dialog : co…

RedHat Linux 7.3基礎環境搭建

文章目錄1&#xff0e;更改主機名2&#xff0e;關閉selinux3&#xff0e;關閉火墻4&#xff0e;重啟機器5&#xff0e;設置ip6&#xff0e;掛載yum源7&#xff0e;升級openssh8&#xff0e;安全基線9&#xff0e;時區10&#xff0e;時間同步11&#xff0e;安裝Vmtools12&#x…

開源http協議庫curl和wget的區別和使用

curl和wget基礎功能有諸多重疊&#xff0c;如下載等。 在高級用途上的curl由于可自定義各種請求參數所以長于模擬web請求&#xff0c;用于測試網頁交互&#xff08;瀏覽器&#xff09;&#xff1b;wget由于支持ftp和Recursive所以長于下載&#xff0c;用于下載文件&#xff08;…

Spring聲明式事務管理、事務的傳播行為xml配置

前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到教程。 1. <tx:method name"insert*" propagation"REQUIRED" />中name的值是ServiceImpl中各個要加入事物管理的方法…

數據結構與算法--9.常見時間復雜度及其之間的關系

文章目錄1.常見時間復雜度2.常見時間復雜度之間的關系1.常見時間復雜度 2.常見時間復雜度之間的關系

CodeIgniter中運用composer安裝依賴包

2019獨角獸企業重金招聘Python工程師標準>>> 基本信息 CodeIgniter 版本&#xff1a;3.1.8Nginx&#xff1a; Tengine/2.1.2 (nginx/1.6.2)MySQL&#xff1a; Ver 14.14 Distrib 5.6.33, for Linux (x86_64) using EditLine wrapperPHP&#xff1a; 5.6.30Zend Engi…

屏幕分辨率

http://cn.screenresolution.org/ 轉載于:https://www.cnblogs.com/qiqi715/p/9363587.html

數據結構與算法--10.利益最大值

1.題目 亞馬遜是一家納斯達克上市的公司&#xff0c;通過其財務報表我們可以解讀它在給定時期內的股票走勢信息。這些信息包括每天交易的最高價&#xff0c;最低價以及開盤價。假定你作為交易員&#xff0c;必須在股票開盤的時候做出買入或者賣出的決定。你負責設計一個算法&a…

shiro管理下MD5加密的使用

前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到教程。 1. 正文&#xff1a; package com.service.impl;import java.util.ArrayList;import java.util.List;import javax.annotation.Resource…

BZOJ2425:[HAOI2010]計數——題解

https://www.lydsy.com/JudgeOnline/problem.php?id2425 https://www.luogu.org/problemnew/show/P2518 你有一組非零數字&#xff08;不一定唯一&#xff09;&#xff0c;你可以在其中插入任意個0&#xff0c;這樣就可以產生無限個數。比如說給定{1,2},那么可以生成數字12,21…

java繼承的問題

一個父類對象變量可以引用該父類的任何一個子類的對象。 但是子類是不能引用父類對象的&#xff0c;這違反類 is-a的規則。