⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menunewmovies.jsp

📁 一个用struts tiles的在线影院web系统
💻 JSP
字号:
<%@ page language="java" contentType="text/html; charset=GB18030"    pageEncoding="GB18030" import="java.util.*,com.eline.vod.utils.caching.*,com.blue.web.common.model.*,com.eline.vod.utils.*,com.eline.vod.client.*,com.eline.vod.model.*" %>
<%!
/* 获取影片简介信息的索引 */
String adjustIntroLength(String str, int length) {
	if (str == null)
		return "不错的电影";
	if (str.length() <= length)
		return str;
	return str.substring(0, length) + "...";}
String showStars(int count) {
	String result = "";
	for (int i = 0; i < count; i ++)
		result += "★";
	return result;
}
%>
<%
// 按最后更新时间倒序获取影片列表
String cacheKey = "movies-new-0-13";
Cache cache = Cache.getInstance();
Page chunk = (Page) cache.get(cacheKey);	// 尝试从cache中获取数据
if (chunk == null) {						// 如果失败则从数据库获取
	Movies movies = new Movies();
	MovieCondition condition = new MovieCondition();
	condition.setSortBy(MovieCondition.SortBy_LastUpdate);
	chunk = movies.searchMovie(condition, 0, 13);
	if (chunk.getItems().size() > 0) {		// 如果有数据则放入cache并设定1分钟超期
		Calendar cal = Calendar.getInstance();
		cal.setTime(new Date());
		cal.add(Calendar.MINUTE, 5);
		cache.add(cacheKey, chunk, cal.getTime(), Cache.NoSlidingExpiration);
	}
}
// 判断影片数目是否为0
boolean isEmptySet = chunk.getItems().size() < 1;
System.out.println("isEmptySet=" + isEmptySet);
String movieURL = SiteUrls2.getInstance().getMovieURL() + "?item=";

%>
<table cellSpacing="1" cellPadding="1" width="100%" border="0">
	<tr>
		<td height="38" valign="top"><a href="<%=SiteUrls2.getInstance().getProperty("new") %>"><img alt="更多内容" border="0" src="<%= request.getContextPath() %>/images/banner-left_new.gif" width="220" height="38"></a></td>
	</tr>
	<tr>
		<td>
		<%if (isEmptySet) { %>
		<table class="body0" cellSpacing="1" cellPadding="3" width="100%">
			<tr><td>影片数为空!</td></tr>
		</table>
		<%}else { %>
		<table class="body0" cellSpacing="1" cellPadding="3" width="100%">
			<%-- 最前面2个大图 + 详细内容 index(0-1) --%><%
			int i, sizeItems = chunk.getItems().size();
			for (i = 0; i < sizeItems && i < 2; i ++) {
				Movie item = (Movie) chunk.getItems().get(i);
				if (item == null)	break;%>			<tr>
				<td><a href="<%=movieURL + item.getIndexID() %>"><img alt="点击进入:<%=item.getTitle() %>" border="0" width="75" height="105" src="<%= request.getContextPath() + ImageProcessor.getThumbFileURL(item.getOrigionFile(), 75, 105) %>" width="70" height="105"></a></td>
				<td>《<a href="<%=movieURL + item.getIndexID() %>"><%=item.getTitle() %></a>》<br />
				简介:<%=adjustIntroLength(item.getIntro(), 25) %><br />
				推荐:<%=showStars(item.getRecommend()) %></td>
			</tr>
			<%} %>
		</table><br/>
		<table class="body0" cellSpacing="1" cellPadding="3" width="100%">
			<tr>
			<%-- 中间3个小图图 index(2-4) --%><%
			int j = i + 3;
			%><%for (; i < sizeItems && i < j; i ++) {
				Movie item = (Movie) chunk.getItems().get(i);%>
				<td><a href="<%=movieURL + item.getIndexID() %>"><img alt="点击进入:<%=item.getTitle() %>" class="imgBorder0" src="<%= request.getContextPath() + ImageProcessor.getThumbFileURL(item.getOrigionFile(), 60, 69) %>" width="60" height="69"></a></td>
			<%} %>
			</tr>
		</table>
		<table class="body0" borderColor="#ffffff" cellPadding="2" width="220"
			bgColor="#f7f1e3" border="1">
			<%-- 最后12个小图图 index(5-12) --%><%
			for (j = 0; i < sizeItems; i ++, j++) {
				Movie item = (Movie) chunk.getItems().get(i);
				if (j % 2 == 0) {%>
			<tr>
				<%} %>
				<td>《<a href="<%=movieURL + item.getIndexID() %>"><%=item.getTitle() %></a>》</td>
				<%if (j % 2 == 1) { %>
			</tr>
				<%} %>
			<%} %>
		</table>
		<%} %>
		</td>
	</tr>
	<tr>
		<td><img src="<%= request.getContextPath() %>/images/footer-left_common.gif"></td>
	</tr>
</table>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -