company查询
查看列表页面controller
@RequestMapping ( path= "/toList" , method = RequestMethod. GET)
public String toList ( ) {
return "company/company-list" ;
}
Test
@Autowired
ICompanyService service;
@Test
public void test01 ( ) {
List< Company> list= service. findAll ( ) ;
System. out. println ( list) ;
}
ICompanyService
List< Company> findAll ( ) ;
CompanyServiceImpl
@Autowired
ICompanyDao dao;
@Override
public List< Company> findAll ( ) {
return dao. findAll ( ) ;
}
ICompanyDao
List< 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 >
controller层
private static final Logger l= LoggerFactory. getLogger ( CompanyController. class ) ;
@Autowired
ICompanyService service;
@RequestMapping ( path = "/toList" , method = RequestMethod. GET)
public String toList ( Model model) {
List< Company> list= service. findAll ( ) ;
l. info ( "list==" , list) ;
model. addAttribute ( "list" , list) ;
return "company/company-list" ;
}
jsp使用foreach迭代
< c: forEach items = " ${list}" var = " item" >
< tr>
< td> < input name = " ids" value = " ${item.id}" type = " checkbox" > </ td>
< td>
${item.name}
</ td>
< td> ${item.city}</ td>
< td> ${item.address}</ td>
< td> ${item.representative}</ td>
< td> ${item.phone}</ td>
< td> ${item.industry}</ td>
< td> ${item.state ==0?'未审核':'已审核'}</ td>
< td class = " text-center" > ${item.balance}</ td>
< td class = " text-center" >
< button type = " button" class = " btn bg-olive btn-xs" onclick = ' #' > 编辑</ button>
</ td>
</ tr>
</ c: forEach>