📄 commentaction.java
字号:
package struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
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 struts.business.CommentManager;
import struts.form.CommentForm;
public class CommentAction extends Action{
private CommentManager cm=new CommentManager();
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception
{
CommentForm cf=(CommentForm)form;
String name=cf.getName();
//System.out.print(name);
String title=cf.getTitle();
//System.out.print(title);
String text=cf.getText();
//System.out.print(text);
String type=cf.getType();
//System.out.print(type);
int floor=Integer.valueOf(cf.getFloor()).intValue()+1;
//System.out.print(floor);
String certcode=cf.getCertcode();
HttpSession session = request.getSession();
String s=(String)session.getAttribute("certCode");
boolean c=s.equals(certcode);
int b=0;
if(isTokenValid(request))
{
this.resetToken(request);
b=cm.insert(name,title,text,type,floor);//添加到数据库;
if(b!=0&&c)
{
System.out.println(b);
return new ActionForward("/comment.jsp");
}
else
{
return mapping.findForward("CommentError");
}
}
else
{
System.out.print("重复提交");
this.saveToken(request);
return new ActionForward("/comment.jsp");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -