📄 comtaction.java
字号:
package com.yhcms.comt.action;
import java.util.ArrayList;
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 com.yhcms.comt.bean.Comment;
import com.yhcms.comt.dao.ComtDaoIm;
import com.yhcms.comt.form.ComtForm;
import com.yhcms.comt.itface.ComtDao;
import com.yhcms.db.DBConnException;
import com.yhcms.utils.DateUtils;
/**
* <p>Title:发表文章评论Action</p>
* <li>发表文章评论</li>
* <br><b>CopyRight: yyhweb[由由华网]</b>
* @author stephen
* @version YH-2.0
*/
public class ComtAction extends Action {
public ActionForward execute(ActionMapping actionmapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
Logger yhlog = Logger.getLogger(ComtShow.class.getName());
ComtForm comtform = (ComtForm)form;
int artId = comtform.getArtId();
String name=comtform.getName();
String email = comtform.getEmail();
String content = comtform.getContent();
String ip = request.getRemoteAddr();
String ptime = DateUtils.getCurFormatDate("yyyy-MM-dd hh:mm:ss");
Comment curCom = new Comment();
curCom.setArtid(artId);
curCom.setName(name);
curCom.setEmail(email);
curCom.setContent(content);
curCom.setIp(ip);
curCom.setPtime(ptime);
ComtDao comtdao = ComtDaoIm.getInstance();
ArrayList comtList = null;
try {
if(comtdao.addComt(curCom)){
yhlog.info("Post one article comment successed,the article id is:"+artId);
}else{
yhlog.info("Post one article comment failed,the article id is:"+artId);
}
comtList = (ArrayList) comtdao.getAllByArtId(artId);
}catch (DBConnException e) {
yhlog.warn("When Post one article comment, throws Exception. the article id is:"+artId);
}
request.setAttribute("artId",artId);
request.setAttribute("comtlist", comtList);
return actionmapping.findForward("Post");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -