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

📄 noteanswer.java

📁 文章管理系统 用Java开发,以Struts为框架,以Jdbc链接Mysql数据库。系统属性:系统属性设置、留言管理、友情链接管理、网站调查、公告管理 关于我们、版权声明、联系我们
💻 JAVA
字号:
package com.yhcms.manage.note.action;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import com.yhcms.db.DBConnException;
import com.yhcms.manage.note.form.NoteAnswerForm;
import com.yhcms.note.bean.Note;
import com.yhcms.note.dao.NoteDaoIm;
import com.yhcms.note.itface.NoteDao;
import com.yhcms.utils.ReqUtils;
/**
 * <p>Title:系统后台留言回答Action</p>
 * <li>显示回答系统留言页面</li>
 * <li>提交留言回答Action</li>
 * <br><b>CopyRight: yyhweb[由由华网]</b>
 * @author stephen
 * @version YH-2.0
 */
public class NoteAnswer extends Action {
	public ActionForward execute(ActionMapping actionmapping,ActionForm form,
			 HttpServletRequest request,HttpServletResponse response) throws UnsupportedEncodingException{
		
			Logger yhlog = Logger.getLogger(NoteAnswer.class.getName());
			ActionMessages errors = new ActionMessages();
			
			NoteAnswerForm anform = (NoteAnswerForm)form;
			Note anNote = new Note();
			// action判断是显示还是提交留言回答
			String action = "";
			action = anform.getAction();
			// 提交留言回答
			if(action.equals("post")){
				int id = anform.getId();
				String author = anform.getAuthor();
				String comeform = anform.getComefrom();
				String weburl = anform.getWeburl();
				String email = anform.getEmail();
				String qq = anform.getQq();
				String title = anform.getTitle();
				String content = anform.getContent();
				String answer = anform.getAnswer();
				
				
				// 设置留言属性
				anNote.setId(id);
				anNote.setAuthor(author);
				anNote.setComefrom(comeform);
				anNote.setWeburl(weburl);
				anNote.setEmail(email);
				anNote.setQq(qq);
				anNote.setTitle(title);
				anNote.setContent(content);
				anNote.setAnswer(answer);
			}
			// 取得要回答的留言Id
			int nId = 0;
			nId = ReqUtils.getInt(request,"nId");
			NoteDao ndao = NoteDaoIm.getInstance();
			Note curNote = null;
			
			try {
				
				if(action.equals("post")){
					if(ndao.answerNote(anNote)){
						return actionmapping.findForward("Success");	
					}else{
						//	 提交留言回答出错.
						action = "";
						yhlog.info("Answer a note unsuccessfully.");
						errors.add("admin.note.answer.fail",new ActionMessage("admin.note.answer.fail"));
						saveErrors(request,errors);
						return actionmapping.findForward("Failure");
					}
					
				}else{ // 取得留言
					curNote = ndao.getNoteById(nId);
					if(curNote==null){
						curNote = new Note();
					}
					request.setAttribute("curNote",curNote);
					return actionmapping.findForward("Display");
				}
				
			} catch (DBConnException e) {
				yhlog.warn("Manage system notes,throw an Exception!");
			}
			return null;
	}
}

⌨️ 快捷键说明

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