真正的action:
package com.itheima.elec.web.action;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.itheima.elec.domain.ElecSystemDDL;
import com.itheima.elec.service.IElecSystemDDLService;
@SuppressWarnings("serial")
@Controller("elecSystemDDLAction")
@Scope(value="prototype")
public class ElecSystemDDLAction extends BaseAction
{
ElecSystemDDL elecSystemDDL = this.getModel();
@Resource(name=IElecSystemDDLService.SERVICE_NAME)
private IElecSystemDDLService elecSystemDDLService;
public String home(){
List list = elecSystemDDLService.findKeywordWithDistinct();
request.setAttribute("list", list);
return "home";
}
public String edit(){
//获取数据类型
String keyword = elecSystemDDL.getKeyword();
//1:使用数据类型作为查询条件,查询数据字典表,返回List
List list = elecSystemDDLService.findSystemDDLListByKeyword(keyword);
request.setAttribute("systemList", list);
return "edit";
}
}
总结:根据什么样的条件查询,是在service层完成的,把所有的条件组织好后,给dao层,dao层再拼接SQL或者hql语句,进行真正的查询。web层的action只是传递参数,进行简单的调用service层的方法。?