FirstAction.java
上传用户:jishiqi_cj
上传日期:2022-08-08
资源大小:24765k
文件大小:1k
源码类别:

Java编程

开发平台:

Java

  1. package StudyNews;
  2. import javax.sql.DataSource;
  3. import java.sql.Connection;
  4. import javax.servlet.ServletContext;
  5. import javax.servlet.http.HttpServletRequest;
  6. import javax.servlet.http.HttpServletResponse;
  7. import javax.servlet.http.HttpSession;
  8. import org.apache.struts.action.Action;
  9. import org.apache.struts.action.ActionForm;
  10. import org.apache.struts.action.ActionForward;
  11. import org.apache.struts.action.ActionMapping;
  12. import org.apache.struts.action.ActionMessage;
  13. import org.apache.struts.action.ActionMessages;
  14. import java.util.Vector;
  15. public final class FirstAction extends Action{  
  16. public ActionForward execute(
  17. ActionMapping mapping,
  18. ActionForm form,
  19. HttpServletRequest request,  
  20. HttpServletResponse response) throws Exception {
  21.     ServletContext context = servlet.getServletContext();
  22. DataSource dataSource = (DataSource)context.getAttribute(Constants.DATASOURCE_KEY);
  23.         DB db = new DB(dataSource);
  24.         HttpSession session = request.getSession();
  25.         
  26. session.setAttribute(Constants.NEWS_LIST_KEY,News.SearchNewsTitle(db));
  27. db.close();
  28.     return (mapping.findForward("toNewsMain"));
  29.   }
  30. }