productaction.java
来自「本系统基本完善了CRM管理系统的各个模块」· Java 代码 · 共 65 行
JAVA
65 行
package com.accp.struts.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONSerializer;
import net.sf.json.JsonConfig;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.LazyDynaBean;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.accp.util.PageResult;
import com.accp.service.ProductService;
public class ProductAction extends DispatchAction {
private ProductService ductService = null;
// 如果没有传递actionType,默认执行这个方法
protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
System.out.println("默认方法...");
// 默认去入口
PrintWriter out = response.getWriter();
out.print("允许访问");
return null;
}
public ActionForward doList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
System.out.println("查询数据");
LazyDynaBean ll = new LazyDynaBean();
BeanUtils.populate(ll, request.getParameterMap());
Map paramMap = ll.getMap();
PageResult pgr = ductService.findAll(paramMap);
System.out.println("总共有" + pgr.getRowCount() + "条数据");
String pgrstr = JSONSerializer.toJSON(pgr).toString();
System.out.println(pgrstr);
out.print(pgrstr);
out.close();
return null;
}
public ProductService getDuctService() {
return ductService;
}
public void setDuctService(ProductService ductService) {
this.ductService = ductService;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?