?? noteanswer.java
字號(hào):
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:系統(tǒng)后臺(tái)留言回答Action</p>
* <li>顯示回答系統(tǒng)留言頁(yè)面</li>
* <li>提交留言回答Action</li>
* <br><b>CopyRight: yyhweb[由由華網(wǎng)]</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();
// 設(shè)置留言屬性
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{
// 提交留言回答出錯(cuò).
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;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -