⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 booklistaction.java

📁 struts+ejb开发简单借书系统,用的是mysql数据库.
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package de.laliluna.tutorial.library.struts.action;

import java.rmi.RemoteException;

import javax.ejb.CreateException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
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 de.laliluna.tutorial.library.session.interfaces.BookSession;
import de.laliluna.tutorial.library.session.interfaces.BookSessionHome;
import de.laliluna.tutorial.library.struts.form.BookListForm;

/** 
 * MyEclipse Struts
 * Creation date: 08-21-2007
 * 
 * XDoclet definition:
 * @struts.action path="/booklist" name="booklistForm" input="/jsp/index.jsp" scope="request" validate="true"
 * @struts.action-forward name="showList" path="/jsp/booklist.jsp"
 */
public class BookListAction 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) {
		BookListForm booklistForm = (BookListForm) form;// TODO Auto-generated method stub

		try {
			InitialContext context = new InitialContext();
			//get the home interface for BookSession with JNDI from the application server
			//holen des Home Interfaces f黵 BookSession mit JNDI vom Appplication Server 
			BookSessionHome bookSessionHome = (BookSessionHome)context.lookup(BookSessionHome.JNDI_NAME);
			BookSession bookSession = bookSessionHome.create();
			
			//get all books and set them in the form bean
			//lies alle B點her aus und setze diese im Form Bean
			
			System.out.println(bookSession+":"+bookSession.getAllBooks()+":"+form);
			
			booklistForm.setBookViews(bookSession.getAllBooks());
			
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (CreateException e) {
			e.printStackTrace();
		}
	    return mapping.findForward("showList");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -