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

📄 artedit.jsp

📁 自己写的一个网络日志(BLOG)系统
💻 JSP
字号:
<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.util.*"%>
<%@ page import="blog.*"%>


<%-- 

//   artedit.jsp
//   文章管理页面
//
 --%>
<%
GregorianCalendar cal = new GregorianCalendar(Locale.CHINA);

			int day = cal.get(Calendar.DAY_OF_MONTH);
			int month = cal.get(Calendar.MONTH) + 1;
			int year = cal.get(Calendar.YEAR);
			String hour = cal.get(Calendar.HOUR_OF_DAY) + "";
			String min = cal.get(Calendar.MINUTE) + "";
			String sec = cal.get(Calendar.SECOND) + "";
			String time = hour + ":" + min + ":" + sec;

			CUserDAO userDao = CUserDAO.newInstance();
			ArrayList userList = userDao.executeQuery();

			CCataDAO cataDao = CCataDAO.newInstance();
			ArrayList cataList = cataDao.executeQuery();

			%>
<HTML>
<HEAD>
<TITLE>Java Coffee-文章编辑</TITLE>
<LINK rev=stylesheet media=screen href="css/admin.css" type=text/css
	rel=stylesheet>
<SCRIPT language=JavaScript src="javasrcipt/common.js"
	type=text/javascript></SCRIPT>
</HEAD>
<BODY>
<%
request.setCharacterEncoding("gbk");
Enumeration eParam = null;
eParam = request.getParameterNames();
ArrayList paraList = null;
paraList = new ArrayList();
while(eParam.hasMoreElements()){
	paraList.add((String)eParam.nextElement());
}
int artID = 0;
int userID = 0;
int cataID = 0;
String action = "";
String artTitle = "";
String artContent = "";
String artIntro ="";
String button = "";
CArticle article = null;
if(paraList.size() != 0){
	
	String[] strType = new String[paraList.size()];
	CArtDAO artDao = CArtDAO.newInstance();
	for(int i = 0 ;i<paraList.size();i++){
		strType[i] = (String )paraList.get(i);	
	}
	String strValue = (String)request.getParameter(strType[0]);
	if(strValue.equals("ArticleDel")){
		String strID = (String)request.getParameter(strType[1]);
		artID = Integer.parseInt(strID);
		article = artDao.queryByID(artID);
		action = "deleteArt";
		artTitle=article.getArtTitle();
		artContent= CStringEncoder.htmlEncoder(article.getArtContent());
		artIntro =CStringEncoder.htmlEncoder(article.getArtIntro());
		userID = article.getUserID();
		cataID = article.getCataID();
		button="删除";
	}else if(strValue.equals("ArticleEdt")){
		String strID = (String)request.getParameter(strType[1]);
		artID = Integer.parseInt(strID);
		article = artDao.queryByID(artID);
		action = "updateArt";
		artTitle=article.getArtTitle();
		artContent= CStringEncoder.htmlEncoder(article.getArtContent());
		artIntro =CStringEncoder.htmlEncoder(article.getArtIntro());
		userID = article.getUserID();
		cataID = article.getCataID();
		button="更新";
	}
}else{
	artTitle="未命名文章";
	artContent="";
	action = "postArticle";
	artIntro ="";
	button="提交";
}
%>
<DIV id=divSidebar>
<DIV id=divTitle><IMG title="RainbowSoft Studio Z-Blog"
	alt="RainbowSoft Studio Z-Blog" src="images/titlezblog.gif"></DIV>
<DIV id=divManage>
<UL>
	<LI><A href="cmd.jsp?act=artmanage">返回</A></LI>
</UL>
</DIV>
</DIV>
<DIV id=divMain2>
<DIV class=form>
<FORM id=edit name=edit method=post action="control.do">
<P>标题:<INPUT id=edtTitle size=56 value=未命名文章 name=artTitle></P>
<P>分类:<SELECT class=edit id=cmbCate
	onchange=artCateID.value=this.options[this.selectedIndex].value size=1>
	<OPTION value=0></OPTION>
	<%for (int i = 0; i < cataList.size(); i++) {
				CCatalog catalog = new CCatalog();
				catalog = (CCatalog) cataList.get(i);
				if(catalog.getCataID() == cataID){%>
					<option value=<%=catalog.getCataID() %> selected><%=catalog.getCataName()%></option>
				<%}else{ %>	
					<option value=<%=catalog.getCataID() %>><%=catalog.getCataName()%></option>
				<% }
	}%>
</SELECT> <INPUT id=artCateID type=hidden value=1 name=artCateID></P>
<P>用户:<SELECT class=edit id=cmbUser
	onchange=artUserID.value=this.options[this.selectedIndex].value size=1 >
	<OPTION value=0 ></OPTION>
	<%for (int i = 0; i < userList.size(); i++) {
				CUser user = new CUser();
				user = (CUser) userList.get(i);
				if(user.getUserID() == userID ){%>
					<option value=<%=user.getUserID() %> selected><%=user.getUserName()%></option>
				<%}else{%>
					<option value=<%=user.getUserID() %>><%=user.getUserName()%></option>
			<%	}
	}%>
</SELECT> <INPUT id=artUserID type=hidden value=1 name=artUserID></P>
<P>日期:<INPUT id=edtYear size=10 value=<%=year%> name=edtYear>年 <INPUT
	id=edtMonth size=10 value=<%=month%> name=edtMonth>月 <INPUT id=edtDay
	size=10 value=<%=day %> name=edtDay>日-<INPUT id=edtTime size=12
	value=<%=time%> name=edtTime></P>
<P></P>
<%if(!action.equals("deleteArt")){ %>
<P>正文:(请不要超过8000字)</P>
<P><TEXTAREA id=artContent onfocus=GetActiveText(this.id);
	onclick=GetActiveText(this.id); name=artContent rows=4 
	onchange=GetActiveText(this.id); value=<%=artContent %>></TEXTAREA></P>
<P>摘要:(请不要超过150字)</P>
<P><TEXTAREA id=artIntro onfocus=GetActiveText(this.id);
	onclick=GetActiveText(this.id); name=artIntro rows=4 
	onchange=GetActiveText(this.id); value=<%=artIntro %>></TEXTAREA></P>
<P><INPUT class=button id=btnPost onclick="return checkArticleInfo();" type=submit value=<%=button %>></P>
<input type="hidden" name="action" value=<%=action %>>  
<input type="hidden" name="module" value="article" /> 
<%if(artID!=0){%>
	<input type="hidden" name="artID" value=<%=artID %> /> 
<%}%>



<SCRIPT>

	objActive="artContent";

	var str10="分类不能为空";
	var str11="正文不能为空";

	function checkArticleInfo(){

		if(document.getElementById("artCateID").value==0){
			alert(str10);
			return false
		}

		if(!document.getElementById("artContent").value){
			alert(str11);
			return false
		}
	}


</SCRIPT>
<%}else{%>
<P><INPUT class=button id=btnPost type=submit value=<%=button %>></P>
<input type="hidden" name="action" value=<%=action %>>  
<input type="hidden" name="module" value="article" /> 
<%if(artID!=0){%>
	<input type="hidden" name="artID" value=<%=artID %> /> 
<%}
}%>
</BODY>
</HTML>

⌨️ 快捷键说明

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