📄 goodsaction.java
字号:
package y2.yxb.web.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import y2.yxb.entity.Goods;
import y2.yxb.hibernatebiz.IGoodsBiz;
import y2.yxb.web.form.GoodsForm;
public class GoodsAction extends BaseAction {
private IGoodsBiz goodsBiz;
// 转到添加商品页面
public ActionForward toAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
return mapping.findForward("add_goods");
}
// 执行添加商品操作
public ActionForward doAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
GoodsForm goodsForm = (GoodsForm) form;
Goods item = goodsForm.getItem();
item.setUser(super.getCurrUser(request));
// item.setSalerId(super.getCurrUserId(request));
try {
this.goodsBiz.addGoods(item);
request.getRequestDispatcher("addgoods.do?op=toOnSaleGoodsList")
.forward(request, response);
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
// 转到在售商品列表页
public ActionForward toOnSaleGoodsList(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
List list = this.goodsBiz.getOnSaleGoodsList();
request.setAttribute("list", list);
return mapping.findForward("index");
}
public IGoodsBiz getGoodsBiz() {
return goodsBiz;
}
public void setGoodsBiz(IGoodsBiz goodsBiz) {
this.goodsBiz = goodsBiz;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -