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

📄 pag.jsp

📁 一个用jsp写的完整的论坛源代码
💻 JSP
字号:
<%@ page contentType="text/html;charset=GBK"%>
<%@ include file="INC/const.jsp"%>
<%@ page import = "java.util.Vector"%>
<script>
function checkForm(f){
	if(f.fromuser.value==''){
		alert('请填写您的姓名');
		f.fromuser.focus();
		return false;
	}
	if(f.touser.value==''){
		alert('请填写您的邮箱');
		f.touser.focus();
		return false;
	}
	if(f.title.value==''){
		alert('请填写邮件标题');
		f.title.focus();
		return false;
	}
	if(f.message.value==''){
		alert('请填写邮件内容');
		f.message.focus();
		return false;
	}
	f.issend.value = '1';
	return true;
}
</script>
<%
	int forumId = ParamUtil.getInt(request, "forumID", 0);
	int rootId = ParamUtil.getInt(request, "rootID", 0);
	int announceId = ParamUtil.getInt(request, "announceID", 0);
	String issend = ParamUtil.getString(request, "issend", "");
	String url = StringUtil.substring(forumURL, forumURL.lastIndexOf("/")) 
				+ "/" + "dispbbs.jsp?forumID="+forumId+"&rootID="+rootId+"&announceID="+announceId;
	String msg = "帖子地址 <a href=" + url + " target=_blank>" + url + "</a>";
	if("1".equals(issend))
	{
		String fromUser = ParamUtil.getString(request, "fromuser", "鲤鱼网");
		String toUser = ParamUtil.getString(request, "touser", "liyunet@yeah.net");
		String title = ParamUtil.getString(request, "title", "一篇不错的文章,时间看一下");
		String message = ParamUtil.getString(request, "message", msg);
		//
		Forum theForum = ForumFactory.getForum(forumId);
		int totalMSGNum = 20;//theForum.getForumMSGsNum();
		int start = 1;
		Vector forumMSGs=theForum.getForumMSGs(forumId,announceId,announceId,start,totalMSGNum);
		//取得前一帖子及下一帖子
		ForumMSGPacker fp = new ForumMSGPacker(forumId, announceId);
		int priID = fp.getPriID();
		String priTopic = fp.getPriTopic();
		int nextID = fp.getNextID();
		String nextTopic = fp.getNextTopic();
		String bgcolor=tableBodyColor;
		String abgcolor=aTableBodyColor;

		String dispbbsStr = "<style>td{font-size:12px}</style><br>相关帖子内容如下<hr noshade size=1>";
		dispbbsStr += "<table cellpadding=0 cellspacing=0 border=0 width=" + tableWidth + " align=center>"
				   +  "<tr><td bgcolor=\""+tableBackColor+"\" valign=middle width=1 height=24></td>"
				   +  "<td bgcolor=\""+tableTitleColor+"\" colspan=2 align=left valign=middle width=*>" 
				   +  "<table cellpadding=0 cellspacing=1 border=0 width=\"100%\">"
		           +  "<tr> <td bgcolor=\""+tableTitleColor+"\" align=left valign=middle width=\"65%\">"
				   +  "<font color=\""+tableFontColor+"\">&nbsp;<b>* 贴子主题</B>: "+fp.getTopic()+"</font></td>"
				   +  "<td width=\"35%\" align=right>"
        		   +  "<a href=\"" + StringUtil.substring(forumURL, forumURL.lastIndexOf("/")) + "/html/dispbbs_"+priID+".html\" alt="+priTopic+">上一主题</a>";
		
        if(nextTopic!=null){
			dispbbsStr += "&nbsp;&nbsp;"
			           +  "<a href=\"" + StringUtil.substring(forumURL, forumURL.lastIndexOf("/")) + "/html/dispbbs_"+nextID+".html\" alt="+nextTopic+">下一主题</a>";
		}
		dispbbsStr += "&nbsp;&nbsp;<a href=# onclick=\"javascript:WebBrowser.ExecWB(4,1)\">保存该页为文件</a>&nbsp;"
		           + "<object id=\"WebBrowser\" width=0 height=0 classid=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></object>"
		    	   + "<a href=#><span style=\"CURSOR: hand\" onClick=\"window.external.AddFavorite('" + StringUtil.substring(forumURL, forumURL.lastIndexOf("/")) + "/html/dispbbs_"+announceId+".html', ' "+forumName+"-"+fp.getTopic()+"')\">"
			 	   + "把本贴加入IE收藏夹</span></a>&nbsp;</td></tr></table></td><td  valign=middle width=1 height=24> </td></tr></table>";
		//
		for (int m=0;m<forumMSGs.size();m++)
		{
			ForumMSG theMSG=(ForumMSG)forumMSGs.get(m);								
			User theUser=theMSG.getUser();
			//		
			dispbbsStr += "<table cellpadding=0 cellspacing=0 border=0 width=\"" + tableWidth + "\" align=center><tr><td bgcolor=\""+tableBackColor+"\" valign=middle width=1 height=24> </td>"
			           +  "<td bgcolor=\""+bgcolor+"\" valign=\"top\"><br>作者:" + theUser.getUserName() + "</td><td width=10 height=\"100%\" ></td>"
			           +  "<td>"
			           + "&nbsp;</td><td style=\"LEFT: 0px; WIDTH: 90%; WORD-WRAP: break-word\">"+"<font face=宋体 color=#333333>"
			           + "<br><b>"+theMSG.getTopic()+"</b><p>"+theMSG.getBody()+"</p><p>&nbsp;</p>"; 
			if (theMSG.getIsVote()&& theMSG.getAnnounceID()==theMSG.getRootID()){
			  	ForumVote theVote=theForum.getForumVote(theMSG.getAnnounceID());
			  	//
			  	String [] votes=theVote.getVoteS();
			  	int [] voteNum=theVote.getVoteNumS();
			  	String voteString="";
			  	int voteSign=0;
			  	for(int voteI=0;voteI<votes.length;voteI++){
			  		if(!votes[voteI].trim().equals("")){
			  			if (theVote.getVoteType()==0){
			  				voteString+=(voteSign+1)+".  <input type=radio name=postVote value=\""+(voteSign)+"\">"+(votes[voteI].trim())+"<br>";
			  			}else{
			  				voteString+=(voteSign+1)+".  <input type=checkbox name=postVote_"+voteSign+" value=\""+voteSign+"\">"+votes[voteI].trim()+"<br>";
			  			  voteSign++;
			  			}
			  		}
			  	}
				
				dispbbsStr += "<table border=0 cellpadding=0 cellspacing=3 width=\"" + tableWidth + "\" align=center><tr>"
				           +  "<td colSpan=2>以下为投票内容:</td></tr>"
						   +  "<tr><td width=\"60%\"><span style=\"LINE-HEIGHT: 200%;\">"+voteString+"</span></td>";
			  	voteString="";
			  	for(int voteI=0;voteI<voteNum.length;voteI++){
			  		voteString+="票数:<font color=#990000><b>"+voteNum[voteI]+"</b></font><br>";
			  	}
			  	dispbbsStr += "<td width=\"40%\" valign=top><span style=\"LINE-HEIGHT: 200%;\">"+voteString+"</span></td></tr>"
				           +  "</tr></table>";
			}
			dispbbsStr += "</td></tr></table>";
			dispbbsStr += "<table cellpadding=0 cellspacing=0 border=0 width=\"" + tableWidth + "\" bgcolor="+tableBackColor+" align=center>"
			           +  "<tr><td height=1> </td></tr></table>";		
			
		}		
		message += dispbbsStr;
		com.bcxy.mail.SendMail.sendMail(toUser, fromUser + title, message);
		out.print("<script>alert('发送成功!');location='"+url+"';</script>");
		return;
	}
%>
<%
	stats=forumName+"把本贴打包邮递.";
	forumID=ParamUtil.getInt(request,"forumID",0);
%>
<%@ include file="INC/theme.jsp"%>
<%
out.println(headLine(1,forumName,forumLogo,"",1,stats,tableWidth));
%>
<%

try{
	if(!foundUser){
		//throw new Exception("请您先登陆!");
	}
%>	
<form action="pag.jsp" method=post name=messager onsubmit="return checkForm(this);">
<input type="hidden" name="issend" value="0">
<input type="hidden" name="forumID" value="<%=forumId%>">
<input type="hidden" name="rootID" value="<%=rootId%>">
<input type="hidden" name="announceID" value="<%=announceId%>">
  <table cellpadding=0 cellspacing=0 border=0 width=<%=tableWidth%> bgcolor=<%=tableBackColor%> align=center>
    <tr> 
      <td> 
        <table cellpadding=3 cellspacing=1 border=0 width=100%>
          <tr> 
            <td bgcolor=<%=tableTitleColor%> colspan=2 align=center> 
              <input type=hidden name="action" value="send">
              <font color="<%=tableFontColor%>"><b>把本贴打包邮递</b>--请完整输入下列信息</font></td>
          </tr>
          <tr> 
            <td bgcolor=<%=tableBodyColor%> valign=middle width=70><font color="<%=tableContentColor%>"><b>发件人:</b></font></td>
            <td bgcolor=<%=tableBodyColor%> valign=middle><font color="<%=tableContentColor%>">
              <input type=text name="fromuser" value="" size=50>&nbsp;您的姓名
            </td>
          </tr>
          <tr> 
            <td bgcolor=<%=tableBodyColor%> valign=middle width=70><font color="<%=tableContentColor%>"><b>收件人:</b></font></td>
            <td bgcolor=<%=tableBodyColor%> valign=middle><font color="<%=tableContentColor%>">
              <input type=text name="touser" value="" size=50>&nbsp;您的邮件地址
            </td>
          </tr>
          <tr> 
            <td bgcolor=<%=tableBodyColor%> valign=top><font color="<%=tableContentColor%>"><b>标题:</b></font></td>
            <td bgcolor=<%=tableBodyColor%> valign=middle><font color="<%=tableContentColor%>">
              <input type=text name="title" size=50 maxlength=80 value=把本贴打包邮递>&nbsp;请限定50字内</font>
            </td>
          </tr>
          <tr> 
            <td bgcolor=<%=tableBodyColor%> valign=top><font color="<%=tableContentColor%>"><b>内容:</b><br></font></td>
            <td bgcolor=<%=tableBodyColor%> valign=middle>
              <textarea cols=70 rows=8 name="message" title=""><%=msg%></textarea>
            </td>
          </tr>
          <tr> 
            <td bgcolor=<%=tableTitleColor%> valign=middle colspan=2 align=center> 
              <input type="submit" value="发送" >
              &nbsp; 
              <input type="reset" name="Clear" value="重置">
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</form>
<%
}catch(Exception e){
	String errMsg=e.getMessage();
	%>
	<%@include file="INC/error.jsp"%>
	<%
}
%>
<%@ include file="foot.jsp"%>

⌨️ 快捷键说明

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