这个问题研究了一天,还是因为配置的时候没有认真,一不小心,酿成了大错。当发现的时候感觉好尴尬啊::>_<::
CostAction:
package com.tenni.action;import java.util.List;import javax.annotation.Resource;import org.springframework.context.annotation.Scope;import org.springframework.stereotype.Controller;import com.tenni.dao.ICostDao;import com.tenni.entity.Cost;@Controller@Scope("prototype")public class CostAction { @Resource private ICostDao costDao; //input private int page = 1; private int pageSize; //output private String msg; private Listlist; private int totalPage; public String findAll(){ list = costDao.findAll(); return "success"; } //分页查询 public String load(){ list = costDao.findByPage(page, pageSize); totalPage = costDao.findTotalPage(pageSize); return "success"; } /** * @return the msg */ public String getMsg() { return msg; } /** * @param msg the msg to set */ public void setMsg(String msg) { this.msg = msg; } /** * @return the list */ public List getList() { return list; } /** * @param list the list to set */ public void setList(List list) { this.list = list; } public ICostDao getCostDao() { return costDao; } public void setCostDao(ICostDao costDao) { this.costDao = costDao; } public int getPage() { return page; } public void setPage(int page) { this.page = page; } public int getPageSize() { return pageSize; } public void setPageSize(int pageSize) { this.pageSize = pageSize; } public int getTotalPage() { return totalPage; } public void setTotalPage(int totalPage) { this.totalPage = totalPage; }}
Struts.xml
/login toLogin /error error /WEB-INF/main/cost.jsp 3 /WEB-INF/main/find_cost.jsp
package----->cost extends---->interceptor(继承了json)
由于使用Spring来管理Action,因此需要通过Spring容器来创建Action,因此class属性指定的是组件的ID。
所以:
costAction 不能写成com.tenni.action.CostAction