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

📄 catalogdispatchaction.java

📁 采用Struts框架做的网上啤酒买卖系统
💻 JAVA
字号:
package com.cavaness.beer4all.catalog;import java.util.List;import org.apache.struts.action.*;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.cavaness.beer4all.service.Beer4AllService;import com.cavaness.beer4all.framework.Beer4AllBaseDispatchAction;import com.cavaness.beer4all.catalog.view.CatalogView;import com.cavaness.beer4all.catalog.view.ItemView;import com.cavaness.beer4all.util.Constants;//这个类处理显示商品信息页面的功能public class CatalogDispatchAction extends Beer4AllBaseDispatchAction{  //获取一个映射,在配置中是转发至beer.jsp  public ActionForward viewItem(ActionMapping mapping,                                ActionForm form,                                HttpServletRequest request,                                HttpServletResponse response)    throws Exception {    //从请求中获取商品ID    String itemId = request.getParameter( Constants.ID_KEY );    //获取一个公共服务接口    Beer4AllService service = getBeer4AllService();    //在商品信息类中获得依据商品ID查找商品信息的服务    ItemView itemView = service.getItemById( itemId );    //将商品信息作为参数置入请求对象中    request.setAttribute( Constants.ITEMVIEW_KEY, itemView );    //获取商品目录列表    List featuredCatalogs = service.getFeaturedCatalogs();    //将商品目录列表作为参数置入请求对象中    request.setAttribute( "featuredCatalogs", featuredCatalogs );    //返回一个成功映射    return mapping.findForward(Constants.SUCCESS_KEY);  }}

⌨️ 快捷键说明

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