查询,打开列表页面

CompanyController

//查询 1 打开列表页面
@RequestMapping(path="/toList",method = RequestMethod.GET)
public String toList(){
return "company/company-list";
}

后台代码

TestCompanyService

@Test
public void test01(){
//1:编写了业务逻辑的测试
//等号 左边是接口 右边是实现类
//ICompanyService service = new CompanyServiceImpl();
List<Company> list = service.findAll();
System.out.println(list);
}

ICompanyService

<Company> findAll();

CompanyServiceImpl

@Autowired
ICompanyDao iCompanyDao;
public List<Company> findAll() {//service要调用dao查询数据,所以要注入
return iCompanyDao.findAll();
}

ICompanyDao

<Company> findAll();

ICompanyDao.xml

<select id="findAll" resultType="company">
select
id,
name ,
expiration_date as expirationDate ,
address,
license_id as licenseId ,
representative ,
phone ,
company_size as companySize ,
industry ,
remarks ,
state,
balance ,
city
from ss_company
</select>

前台代码

CompanyController

//查询 1 打开列表页面
@RequestMapping(path="/toList",method = RequestMethod.GET)
public String toList(Model model){
//调service获取数据
List<Company> list = iCompanyService.findAll();
l.info("toList list="+list);
model.addAttribute("list",list);
//将数据发到页面,使用标签
return "company/company-list";
}

company-list.jsp

使用foreach与el表达式等显示。