WEB4J是一个Java Web应用框架,目标是让使用者建立简单,清晰和优雅的web应用。该框架同时也提供一个开发者工具来协助开发人员创建基于 WEB4J的 应用程序。
下面是一个 WEB4J 的Action类源码:
package hirondelle.electricity.main.report; import hirondelle.electricity.util.TemplatedPage; import hirondelle.web4j.model.AppException; import hirondelle.web4j.action.ActionImpl; import hirondelle.web4j.request.RequestParser; import hirondelle.web4j.action.ResponsePage; import hirondelle.web4j.database.SqlId; public class ReportAction extends ActionImpl { public static final SqlId LIST_HIGH_SPENDING = new SqlId("LIST_HIGH_SPENDING"); public ReportAction(RequestParser aRequestParser){ super(FORWARD, aRequestParser); } @Override public ResponsePage execute() throws AppException { ReportDAO dao = new ReportDAO(); addToRequest(ITEMS_FOR_LISTING, dao.list()); return getResponsePage(); } // PRIVATE // private static final ResponsePage FORWARD = TemplatedPage.get( "Example Report", "view.jsp", ReportAction.class ); }