日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ssm框架下 tiles框架 的使用

發布時間:2023/12/18 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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>

?

?

?

?

?

?

?

?

?

總結

以上是生活随笔為你收集整理的ssm框架下 tiles框架 的使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。