📄 newtopicaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.wsy.struts.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.sql.DataSource;
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.ActionMessages;
import com.wsy.struts.bean.ForumBean;
import com.wsy.struts.bean.LoginBean;
import com.wsy.struts.form.NewtopicForm;
/**
* MyEclipse Struts
* Creation date: 11-08-2007
*
* XDoclet definition:
* @struts.action path="/newtopic" name="newtopicForm" input="/newarticle.jsp" scope="request" validate="true"
*/
public class NewtopicAction 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) {
DataSource datasource = getDataSource(request,"dataSources");//取struts配置的数据源
NewtopicForm newtopicForm = (NewtopicForm) form;// TODO Auto-generated method stub
ActionMessages error=new ActionMessages();
HttpSession session=request.getSession();
String name=newtopicForm.getName();
String forumid=newtopicForm.getForumid();
String forumname=null;
if(forumid==null){
forumid=(String)session.getAttribute("forumId");
}
ForumBean forum=new ForumBean();
List forumnlist=forum.getRecord(datasource, forumid);
for(int i=0;i<forumnlist.size();i++){
ForumBean forums=(ForumBean)forumnlist.get(i);
forumname=forums.getForumnname();
}
String topicname=(String)session.getAttribute("title");
System.out.println(topicname);
System.out.println(name);
System.out.println("forumname"+forumname);
System.out.println("forumid"+forumid);
session.setAttribute("name", name);
session.setAttribute("forumid", forumid);//将用户名与论坛号以及论坛名称传入发表新主题页面
session.setAttribute("forumname", forumname);
String type=newtopicForm.getType();
System.out.println("type"+type);
session.setAttribute("type", type);
LoginBean login=new LoginBean();
List list=login.getRecordForUser(name, datasource);//取出这个用户所有相关信息
session.setAttribute("listuser",list);
return mapping.getInputForward();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -