b04bdea24217001c1becd919ef928150
来自「使用JSP+Servlet+Hibernate+Struts实现的一个学生软件发」· 代码 · 共 73 行
TXT
73 行
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package edu.neu.struts.action;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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 edu.neu.sspp.TextAreaConventer;
import edu.neu.sspp.hibernate.TComment;
import edu.neu.sspp.hibernate.TCommentDAO;
import edu.neu.sspp.hibernate.TProject;
import edu.neu.struts.form.CommentForm;
/**
* MyEclipse Struts
* Creation date: 06-10-2007
*
* XDoclet definition:
* @struts.action path="/comment" name="commentForm" input="/proj_jsp/proj_info.jsp" scope="request" validate="true"
*/
public class CommentAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
CommentForm commentForm = (CommentForm) form;// TODO Auto-generated method stub
TComment comment = new TComment();
TCommentDAO commentDAO = new TCommentDAO();
String content = TextAreaConventer.convertToHtml(commentForm.getContent());
if(content.length() > 500)
content = content.substring(0, 500);
comment.setContent(content);
if(commentForm.getIsUser())
comment.setIsUser(new Byte((byte)1));
else
comment.setIsUser(new Byte((byte)0));
if(commentForm.getNick() == null || commentForm.getNick().equals(""))
comment.setNick("匿名");
else
comment.setNick(commentForm.getNick());
comment.setDate(new Date());
comment.setTProject((TProject)request.getAttribute("project"));
return mapping.findForward((String)request.getAttribute("url"));
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?