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

📄 browse.jsp

📁 struts spring hibernate制作的留言本
💻 JSP
字号:
<%@page contentType="text/html; charset=GBK"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@page import="anni.gbook.BoardInfo"%>
<%@page import="anni.tools.*"%>
<%@ include file="config.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><%=gbname%></title>
<meta http-equiv=Content-Type content="text/html; charset=GBK">
<LINK href="<%=styleFile%>" rel=stylesheet>
<script type="text/javascript" src="check.js"></script>
<script language="JavaScript">

var limit_name = <%=limit_name%>;
var limit_email = <%=limit_email%>;
var limit_pagename = <%=limit_pagename%>;
var limit_pageurl = <%=limit_pageurl%>;
var limit_text = <%=limit_text%>;

function ow(url)
{
	window.open(url,'','width=640,height=400,resizable=yes,scrollbars=1,directories=no');
	return;
}
function check()
{
	var item = document.form1;

	if(item.newname.value=="")
	{
		alert("请输入您的姓名");
		item.newname.focus();
		return;
	}
	if(!checkSafe(item.newname.value))
	{
		alert("姓名不能包括&;`'\\\"|*?~<>^()[]{}$\\n\\r");
		item.newname.focus();
		return;
	}
	if(checkLength(item.newname.value) > limit_name)
	{
		alert("昵称最长不能超过"+limit_name+"位字符");
		item.newname.focus();
		return;
	}

	if(!checkEmail(item.newemail.value))
	{
		alert("请输入有效的email");
		item.newemail.focus();
		return;
	}
	if(checkLength(item.newemail.value) > limit_email)
	{
		alert("EMAIL最长不能超过"+limit_email+"位字符");
		item.newemail.focus();
		return;
	}

	if(item.newpageurl.value!="" && item.newpageurl.value!="http://" && !checkUrl(item.newpageurl.value))
	{
		alert("请输入有效的url");
		item.newpageurl.focus();
		return;
	}
	if(checkLength(item.newpagename.value) > limit_pagename)
	{
		alert("主页名称最长不能超过"+limit_pagename+"位字符");
		item.newpagename.focus();
		return;
	}
	if(checkLength(item.newpageurl.value) > limit_pageurl)
	{
		alert("主页地址最长不能超过"+limit_pageurl+"位字符");
		item.newpageurl.focus();
		return;
	}

	if(item.newtext.value=="")
	{
		alert("请输入留言内容");
		item.newname.focus();
		return;
	}
	if(!checkSafe(item.newtext.value))
	{
		alert("留言内容不能包括&;`'\\\"|*?~<>^()[]{}$\\n\\r");
		item.newtext.focus();
		return;
	}
	if(checkLength(item.newtext.value) > limit_text)
	{
		alert("留言最长不能超过"+limit_text+"位字符");
		item.newtext.focus();
		return;
	}

	item.action="board-add.do?method=add";
	item.submit();
}
</script>
</head>
<body>
<center>
<!-------------------->
<p>
<table cellpadding='4' cellspacing='0' border='0' width='80%' align='center' class="write">
 <tr bgcolor="#eeeeef">
  <td>
  <center><b><%=gbname%>--打<font color=red>*</font>号的必填 </b></center>
  <hr size=1 color=gray>
<table border=0 cellpadding=3 cellspacing=2 width="100%" align="center" ><form name="form1" action="gb_write.jsp" method="post" ><%String token = String.valueOf(System.currentTimeMillis()); session.setAttribute("token",token);%><input type="hidden" name="token" value="<%=token%>">
        <tr> 
          <td width=20%>你的姓名:<font color=red>*</font></td>
          <td width=30%><input type="text" name="newname"></td>
          <td width=20%>电子邮件:<font color=red>*</font></td>
          <td width=30%> <input type="text" name="newemail"></td>
        </tr>
        <tr> 
          <td width=20%>主页名称:</td>
          <td width=30%><input type="text" name="newpagename"></td>
          <td width=20%>主页地址:</td>
          <td width=30%><input type="text" name="newpageurl" value="http://"></td>
        </tr>
        <tr>
          <td width=20%>性别:</td>
          <TD width=40%><font color="#b50000">男 </font><input type="radio" name="sex" value="0" checked> &nbsp;&nbsp;<font color="#19C108">女</font>
            <input type="radio" name="sex" value="1"></td>
          <td width=10%>个性头像:</td>
		  <td width=30%>
		  <select size=1 name="img" onChange="document.images['face'].src=options[selectedIndex].value;">
<%
	for(int imgi=1;imgi<=59;imgi++)
	{
		String s =  "Image"+imgi+".gif";
		out.println("<option value=images/"+s+">"+s+"</option>");
	}
%>
		  </select>&nbsp;<a href="javascript:ow('gb_img.jsp');" title="查看所有头像"><img src="images/Image1.gif" border=0 name="face" width=32 height=32></a>
		  </td>
        </tr>
        <tr> 
          <td>留言内容:<font color=red>*</font><br><font color=#336699>支持JUBB(类似UBB代码),具体支持哪些代码自己试吧</font></td>
          <td colspan="3"><textarea name="newtext" cols="50" rows="8"></textarea></td>
		  </tr>
        <tr> 
          <td colspan="4"><div align="center">
              <input type="button" name="Submit" value="提交" onclick="check()">
              &nbsp; 
              <input type="reset" name="Submit2" value="重填">
            </div></td>
        </tr></form>
      </table>
 </td>
 </tr>
</table>
</p><!-------------------->
<%
	List all = (List)request.getAttribute("all");
	//System.out.println("all : "+all);

	int count = all.size();

	String currentPage0 = (String)request.getAttribute("currentPage");
	int currentPage = 0;

	try
	{
		currentPage = Integer.parseInt(currentPage0);
	}
	catch (NumberFormatException ex)
	{
		ex.printStackTrace();
	}
	if(currentPage<0 || currentPage>count/6)
	{
		currentPage=0;
	}

	UBB2 ubb = new UBB2();
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	int id;
	String name;
	String email;
	String pageName;
	String pageUrl;
	int sex;
	String img;
	String content;
	String ip;
	Date dateTime;
	String reply;

	String emailMessage;
	String homePage;
	String dateFormat;
	String contentFormat;
	String username;

	BoardInfo info;

	int pageNum = (count+6-1)/6;//总共多少页
	int start = currentPage*6;
	int end = (currentPage+1)*6;
	if(end>count)
	{
		end=count;
	}

	//System.out.println(start+"|"+end);

	for(int i=start;i<end;i++)
	{
		info = (BoardInfo)all.get(i);

		//id = info.getId().intValue();
		id = info.getId();
		name = info.getName();
		email = info.getEmail();
		pageName = info.getPageName();
		pageUrl = info.getPageUrl();
		//sex = info.getSex().intValue();
		sex = info.getSex();
		img = info.getImg();
		content = info.getContent();
		ip = info.getIp();
		dateTime = info.getDateTime();
		reply = info.getReply();

		if(sex==0)
		{
			//男人
			username = "<font color=#b50000><b>"+name+"</b></font>";
		}
		else
		{
			//女人
			username = "<font color=#19C108><b>"+name+"</b></font>";
		}

		if(email == null || email.equals(""))
		{
			emailMessage = "<font color=gray>邮件</font>";
		}
		else
		{
			emailMessage = "<a href=\"mailto:"+email+"\" title=\"给"+name+"写信\">邮件</a>";
		}

		if(pageName == null || pageName.equals("") || pageUrl == null || pageUrl.equals(""))
		{
			homePage = "<font color=gray>主页</font>";
		}
		else
		{
			homePage = "<a href="+pageUrl+" target=_blank title=访问"+name+"的主页《"+pageName+"》>主页</a>";
		}

		contentFormat = content;
		contentFormat = contentFormat.replaceAll("<","&lt;");
		contentFormat = contentFormat.replaceAll(">","&gt;");
		contentFormat = contentFormat.replaceAll("\r\n","<br>");
		contentFormat = ubb.reAll(content);
		dateFormat = sdf.format(dateTime);
%>
<table cellpadding="5" cellspacing="1" border="0" width="80%" align="center" class="write" style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all; WORD-WRAP: break-word">
<tr>
  <td colspan="4"><p><img src="<%=img%>" border="0" align="left"><%=contentFormat%></p></td>
</tr>
<%
	if(reply != null && !reply.equals(""))
	{
%>
<tr>
  <td colspan=4 width="100%">
    <table cellspacing=1 cellpadding=3 bgcolor=black width="98%">
	<tr bgcolor=#feffef>
	  <td><p>回复:<br><font color=#9800cc><%=reply%></font></p></td>
	</tr>
	</table>
  </td>
</tr>
<%
	}
%>
    <tr bgcolor="#eeefff" align="center"><td align="left" width="35%">
	昵称:<%=username%></td>
		<Td width="25%"><font color="#7489ff"><%=dateFormat%></font></td>
    	<Td width="10%"><%=homePage%>&nbsp;&nbsp;<%=emailMessage%></td>
		<td width="30%" bgcolor="#eeeeee"><a href="viewip.jsp?id=<%=id%>" title="查看IP" target="_blank">查看IP</a>&nbsp;&nbsp;<a href="board.do?method=viewReply&id=<%=id%>" title="回复留言">回复</a>&nbsp;&nbsp;<a href="delete.jsp?id=<%=id%>" title="删除留言">删除</a>
	</td></tr>
</table>

<table cellspacing=0 cellpadding=0 width=100% height=10><tr><td></td></tr></table>
<%
	}
%>
<table cellspacing=1 cellpadding=3 width=80% height=30 bgcolor="black"><Tr bgcolor="#eeeeff"><Td>
<%
//开始分页
	if(pageNum>1)
	{
		out.println("共有留言<font color=red>"+count+"</font>条,共有<font color=red>"+pageNum+"</font>页");
		for(int pgi = 1;pgi <= pageNum;pgi++)
		{
			if(pgi == currentPage+1)
			{
				out.println("<font color=gray>第"+pgi+"页</font>");
			}
			else
			{
				//out.println("<a href="+request.getRequestURL()+"?pg="+pgi+" title=第"+pgi+"页>第"+pgi+"页</a>");
				out.println("<a href=board.do?method=browse&currentPage="+(pgi-1)+
					" title=第"+pgi+"页>第"+pgi+"页</a>");
			}
		}
	}
	else
	{
		out.println("当前只有<font color=red>1</font>页,共<font color=red>"+count+"</font>条留言");
	}
%>
</td></tr></table>
<p><%@include file="copyright.jsp"%></p>
</center>
</body>
</html>

⌨️ 快捷键说明

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