JavaWeb项目开发案例精粹-第4章博客网站系统-006View层

时间:2024-05-19 18:36:32

1.showAllArticle.jsp

 <%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>博客系统首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="css/main.css" media="all" />
<!--[if IE 6]><link type="text/css" rel="stylesheet" href="css/ie6.css" media="all" /><![endif]-->
<script type="text/javascript" src="js/mootools.js"></script>
<script type="text/javascript" src="js/site.js"></script>
</head>
<body>
<div id="wrapper">
<div id="container">
<div id="scene"> c<img src="data:images/scene.jpg" alt="" />
<h1>博客网站系统</h1>
<div id="scale_area">
<div id="scale_knob">&raquo; Font Size &laquo;</div>
</div>
<div id="menu">
<div class="holder"> <a href="showAllArticle.action">博客首页</a> </div>
<div class="holder"> <a href="register.jsp">新博客注册</a> </div>
<div class="holder"> <a href="login.jsp">博客登录</a> </div>
</div>
</div>
<div id="content">
<div id="col_left">
<div class="post">
<div class="meta"><a class="title" href="">博客系统首页</a>
<div class="clear"></div>
</div>
<!-- 循环输出 -->
<s:iterator value="#request.all" id="art" status="sta">
<div class="comments">
<div class="comment">
<div class="meta"> <span><a href="user/showArticle.action?username=<s:property value='#art.username'/>&id=<s:property value='#art.id'/>"><s:property value="#art.title"/></a> <small>:</small></span>
<div class="clear"> </div>
</div>
</div>
<div class="comment alt">
<div class="meta"><span class="datetime">
<!-- 发表时间 -->
发表于:
<s:date name="#art.date"/>
<!-- 评论与点击数 -->
|评论(<s:property value="#request.critiqueCounts[#sta.index]"/>)|点击(<s:property value="#art.hasread"/>)|作者:<s:property value="#art.username"/>
</span>
<div class="clear"> </div>
</div>
</div>
</div>
</s:iterator>
<div class="comment" align="center">
当前第${page.currentPage}页,共${page.totalPage}页,每页显示${page.everyPage}条记录
<s:if test="#request.page.hasPrePage">
<a href="showAllArticle.action?currentPage=1">首页</a>
<a href="showAllArticle.action?currentPage=${page.currentPage -1 }">上一页</a>
</s:if>
<s:else>
首页
上一页
</s:else> <s:if test="#request.page.hasNextPage">
<a href="showAllArticle.action?currentPage=${page.currentPage + 1 }">下一页</a>
<a href="showAllArticle.action?currentPage=${page.totalPage }">尾页</a>
</s:if>
<s:else>
下一页
尾页
</s:else>
</div>
</div>
</div>
<div id="col_right">
<div id="search_box">
<form action="http://www.865171.cn/" method="post">
<div>
<input type="text" name="search" />
</div>
<div class="button_wrapper">
<input type="submit" value="Search" class="button" />
</div>
<div class="clear"> </div>
</form>
</div>
<div id="sidebar">
<h2>页面导航</h2>
<ul>
<li><a href="showAllArticle.action">博客首页</a></li>
<li><a href="register.jsp">新博客注册</a></li>
<li><a href="login.jsp">博客登录</a></li>
</ul>
</div>
</div>
<div class="clear"> </div>
</div>
<div id="footer">
<div class="clear"> </div>
<hr />
<p class="credit">博客网站系统</p>
</div>
</div>
</div>
</body>
</html>

2.login.jsp

 <%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>博客系统登录</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="css/main.css" media="all" />
<!--[if IE 6]><link type="text/css" rel="stylesheet" href="css/ie6.css" media="all" /><![endif]-->
<script type="text/javascript" src="js/mootools.js"></script>
<script type="text/javascript" src="js/site.js"></script>
</head>
<body>
<div id="wrapper">
<div id="container">
<div id="scene"> <img src="data:images/scene.jpg" alt="" />
<h1>博客网站系统</h1>
<div id="scale_area">
<div id="scale_knob">&raquo; Font Size &laquo;</div>
</div>
<div id="menu">
<div class="holder"> <a href="showAllArticle.action">博客首页</a> </div>
<div class="holder"> <a href="register.jsp">新博客注册</a> </div>
<div class="holder"> <a href="login.jsp">博客登录</a> </div>
</div>
</div>
<div id="content">
<div id="col_left">
<div class="post">
<div class="meta"></div>
<div class="comments"><div class="comment"></div>
<h2>博客登录</h2>
<form class="h" action="login.action" method="post">
<div>
<label>用户名:</label>
<input type="text" name="username" />
</div>
<div>
<label>密码:</label>
<input type="password" name="password" />
</div>
<div>
<label></label>
<div class="clear"> </div>
</div>
<div class="button_wrapper">
<input name="提交" type="submit" class="button" value="登录" />
</div>
</form>
</div>
</div>
</div>
<div id="col_right">
<div id="search_box">
<form action="" method="post">
<div>
<input type="text" name="search" />
</div>
<div class="button_wrapper">
<input type="submit" value="Search" class="button" />
</div>
<div class="clear"> </div>
</form>
</div>
<div id="sidebar">
<h2>页面导航</h2>
<ul>
<li><a href="showAllArticle.action">博客首页</a></li>
<li><a href="register.jsp">新博客注册</a></li>
<li><a href="login.jsp">博客登录</a></li>
</ul>
</div>
</div>
<div class="clear"> </div>
</div>
<div id="footer">
<div class="clear"> </div>
<hr />
<p class="credit">博客网站系统</p>
</div>
</div>
</div>
</body>
</html>

3.user/showAllUserArticle.jsp

 <%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>我的全部文章</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="../css/main.css" media="all" />
<!--[if IE 6]><link type="text/css" rel="stylesheet" href="css/ie6.css" media="all" /><![endif]-->
<script type="text/javascript" src="../js/mootools.js"></script>
<script type="text/javascript" src="../js/site.js"></script>
</head>
<body>
<div id="wrapper">
<div id="container">
<div id="scene"> c<img src="../images/scene.jpg" alt="" />
<h1>${empty sessionScope.blogtitle ? "博客网站系统":sessionScope.blogtitle} <br/>
<font size="8">${empty sessionScope.idiograph ? "我的签名":sessionScope.idiograph}</font>
</h1>
<div id="scale_area">
<div id="scale_knob">&raquo; Font Size &laquo;</div>
</div>
<div id="menu">
<div class="holder"> <a href="../showAllArticle.action">博客首页</a> </div>
<div class="holder"> <a href="showUserAllArticle.action">用户首页</a> </div>
<div class="holder"> <a href="editbloginfo.jsp">个性化设置</a> </div>
<div class="holder"> <a href="addArticle.jsp">写日志</a> </div>
<div class="holder"> <a href="showPhoto.action">相册</a> </div>
</div>
</div>
<div id="content">
<div id="col_left">
<div class="post">
<div class="meta"><a class="title" href="">我的全部文章</a>
<div class="clear"></div>
</div>
<!-- 循环输出 -->
<s:iterator value="#request.all" id="art" status="sta">
<div class="comments">
<div class="comment">
<div class="meta"> <span><a href="showArticle.action?username=<s:property value='#art.username'/>&id=<s:property value='#art.id'/>"><s:property value="#art.title"/></a> <small>:</small></span>
<div class="clear"> </div>
</div>
</div>
<div class="comment alt">
<div class="meta"><span class="datetime">
<!-- 发表时间 -->
发表于:
<s:date name="#art.date"/>
<!-- 评论与点击数 -->
|评论(<s:property value="#request.critiqueCounts[#sta.index]"/>)|点击(<s:property value="#art.hasread"/>)
</span>
<div class="clear"> </div>
</div>
</div>
</div>
</s:iterator>
<div class="comment" align="center">
当前第${page.currentPage}页,共${page.totalPage}页,每页显示${page.everyPage}条记录
<s:if test="#request.page.hasPrePage">
<a href="showUserAllArticle.action?currentPage=1">首页</a>
<a href="showUserAllArticle.action?currentPage=${page.currentPage -1 }">上一页</a>
</s:if>
<s:else>
首页
上一页
</s:else> <s:if test="#request.page.hasNextPage">
<a href="showUserAllArticle.action?currentPage=${page.currentPage + 1 }">下一页</a>
<a href="showUserAllArticle.action?currentPage=${page.totalPage }">尾页</a>
</s:if>
<s:else>
下一页
尾页
</s:else>
</div>
</div>
</div>
<div id="col_right">
<div id="search_box">
<form action="" method="post">
<div>
<input type="text" name="search" />
</div>
<div class="button_wrapper">
<input type="submit" value="Search" class="button" />
</div>
<div class="clear"> </div>
</form>
</div>
<div id="sidebar">
<h2>页面导航</h2>
<ul>
<li><a href="../showAllArticle.action">博客首页</a></li>
<li><a href="showUserAllArticle.action">用户首页</a></li>
<li><a href="editbloginfo.jsp">个性化设置</a></li>
<li><a href="addArticle.jsp">写日志</a></li>
<li><a href="showPhoto.action">相册</a></li>
</ul>
</div>
</div>
<div class="clear"> </div>
</div>
<div id="footer">
<div class="clear"> </div>
<hr />
<p class="credit">博客网站系统</p>
</div>
</div>
</div>
</body>
</html>

4.site.js

 var s = {

     start: function() {
s.ieDetect();
s.resizeCols();
s.setFont();
s.textScaler();
}, ieDetect: function() {
s.IEVersion = false;
var rv = -1;
if ( navigator.appName == 'Microsoft Internet Explorer' ) {
var ua = navigator.userAgent;
var re = new RegExp( "MSIE ([0-9]{1,}[\.0-9]{0,})" );
if ( re.exec( ua ) != null )
s.IEVersion = parseFloat( RegExp.$1 );
}
}, resizeCols: function() {
if( s.IEVersion != 6 ) {
var col_left = $( 'col_left' ).getStyle( 'height' ).toInt();
var col_right = $( 'col_right' ).getStyle( 'height' ).toInt();
if( col_left > col_right ) {
$( 'col_right' ).setStyle( 'height', ( ( col_left + 40 ) / 10 ) + 'em' );
}
if( col_right > col_left )
$( 'col_left' ).setStyle( 'height', ( col_right / 10 ) + 'em' );
}
}, setFont: function() {
if( Cookie.read( 'semfont' ) ) {
var size = Cookie.read( 'semfont' );
$( 'wrapper' ).setStyle( 'font-size', size + 'px' );
s.fontSize = size.toFloat();
}
else
s.fontSize = 10;
}, textScaler: function() {
var begin = ( s.fontSize == 10 ) ? 0 : ( s.fontSize - 10 ) * 10;
new Slider( $( 'scale_area' ), $( 'scale_knob' ), {
steps: 100,
onChange: function( pos ) {
var size = ( ( pos.toInt() / 10 ) + 10 );
$( 'wrapper' ).setStyle( 'font-size', size + 'px' );
},
onComplete: function( pos ) {
var size = ( ( pos.toInt() / 10 ) + 10 );
if( Cookie.read( 'semfont' ) )
Cookie.dispose( 'semfont' );
Cookie.write( 'semfont', size, { path: '/', duration: 28 } );
s.fontSize = size;
}
} ).set( begin );
}
} window.addEvent( 'domready', s.start );

5.user/showPhotos.jsp

 <%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>相册</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="../css/main.css" media="all" />
<!--[if IE 6]><link type="text/css" rel="stylesheet" href="css/ie6.css" media="all" /><![endif]-->
<script type="text/javascript" src="../js/mootools.js"></script>
<script type="text/javascript" src="../js/site.js"></script>
<script type="text/javascript">
var GB_ROOT_DIR = "./greybox/";
</script>
<script type="text/javascript" src="greybox/AJS.js"></script>
<script type="text/javascript" src="greybox/AJS_fx.js"></script>
<script type="text/javascript" src="greybox/gb_scripts.js"></script>
<link href="greybox/gb_styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="container">
<div id="scene"> <img src="../images/scene.jpg" alt="" />
<h1>${empty sessionScope.blogtitle ? "博客网站系统":sessionScope.blogtitle} <br/>
<font size="8">${empty sessionScope.idiograph ? "我的签名":sessionScope.idiograph}</font>
</h1>
<div id="scale_area">
<div id="scale_knob">&raquo; Font Size &laquo;</div>
</div>
<div id="menu">
<div class="holder"> <a href="../showAllArticle.action">博客首页</a> </div>
<div class="holder"> <a href="showUserAllArticle.action">用户首页</a> </div>
<div class="holder"> <a href="editbloginfo.jsp">个性化设置</a> </div>
<div class="holder"> <a href="addArticle.jsp">写日志</a> </div>
<div class="holder"> <a href="showPhoto.action">相册</a> </div>
</div>
</div>
<div id="content">
<div id="col_left">
<div class="post">
<div class="meta"></div>
<div class="comments">
<h2>上传图片</h2>
<form action="photoUpload.action" method="post" enctype="multipart/form-data">
<div>
<label>选择要上传的图片:</label>
<input type="file" name="myFile"/>
</div>
<div>
<label></label>
<div class="clear"> </div>
</div>
<div class="button_wrapper">
<input name="提交" type="submit" class="button" value="上传" />
</div>
</form>
</div> <div class="comments">
<h2>显示相册图片</h2>
<table cellspacing="5" align="center" border="1">
<tr>
<s:iterator value="#request.photoList" id="photo" status="stu">
<td>
<a href='photo/${sessionScope.username}/<s:property value="photo"/>' title="我的相册" rel="gb_imageset[photos]">
<img src='photo/${sessionScope.username}/<s:property value="photo"/>' width="100" height="120">
</a>
</td>
<s:if test="(#stu.index + 1) % 3 == 0">
</tr>
<tr>
</s:if>
</s:iterator>
</table>
</div>
</div>
</div>
<div id="col_right">
<div id="search_box">
<form action="" method="post">
<div>
<input type="text" name="search" />
</div>
<div class="button_wrapper">
<input type="submit" value="Search" class="button" />
</div>
<div class="clear"> </div>
</form>
</div>
<div id="sidebar">
<h2>页面导航</h2>
<ul>
<li><a href="../showAllArticle.action">博客首页</a></li>
<li><a href="showUserAllArticle.action">用户首页</a></li>
<li><a href="editbloginfo.jsp">个性化设置</a></li>
<li><a href="addArticle.jsp">写日志</a></li>
<li><a href="showPhoto.action">相册</a></li>
</ul>
</div>
</div>
<div class="clear"> </div>
</div>
<div id="footer">
<div class="clear"> </div>
<hr />
<p class="credit">博客网站系统</p>
</div>
</div>
</div>
</body>
</html>

6.mainHeader.jsp

 <%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
<!--
function mhEnter()
{
window.event.srcElement.className="lt1";
}
function mhLeave()
{
window.event.srcElement.className="lt0";
}
//-->
</script>
<link rel="stylesheet" href="../image/style.css">
</head> <body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr height="31">
<td background="image/line.jpg">
<table width="1000" border="0" cellpadding="0" cellspacing="0">
<tr height="20" align="center">
<td width="278">&nbsp;</td>
<td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="showAllArticle.action">博客首页</a></td>
<td class="ltsep">|</td>
<td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="register.jsp">新博客注册</a></td>
<td class="ltsep">|</td>
<td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="login.jsp">博客登陆</a></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>