☝:Mybatis ------ ***Mapper
// 按名称查询
List<Company> getComp(@Param("compName")String compName);
***Mapper.xml
<select id="getComp" resultType="Company">
select * from company where compName like "%"#{compName}"%"
</select>
✌:Service ----- ***Service
// 按名字查询
List<Company> getComp(String compName);
***ServiceImpl
public List<Company> getComp(String compName) {
return companyMapper.getComp(compName);
}
?:Controller ----- ***Controller
@RequestMapping("/getCompName")
public String getComp(Model model, String compName){
System.out.println(compName);
List<Company> comp = companyService.getComp(compName);
model.addAttribute("searchName",comp);
return "test";
}
?:Web ----- ***.jsp
<form action="${pageContext.request.contextPath}/company/getCompName" method="post">
查询<input type="text" name="compName">
<input type="submit" value="提交">
</form>
版权声明:本文为weixin_45296482原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。