controller接受参数并设置页面里的结果,接受的参数与页面的设置有关
//这里写注解,不然扫描不到.do
@Controller
public class WarehouseCheckController {
@Autowired
UserService ser;//要使用的service
@RequestMapping(value="Warehouse_Check_ProductShelfRelation.do",method={RequestMethod.GET,RequestMethod.POST})
//value里指明这个函数对应的.do
//页面里的action跳转时设置action="Warehouse_Check_ProductShelfRelation.do"就转到这个函数来处理
public ModelAndView linchao(HttpServletRequest request,Shelf sh){//这里加了HttpServletRequest参数,由页面传入,Shelf类由页面里的表单post而来
ModelAndView modelAndView=new ModelAndView();
modelAndView.setViewName("Warehouse_Check");
List list=ser.findAll();
request.setAttribute("atrlist",list);//这里注入list类参数
request.setAttribute("amount",13);//这里注入单个参数
return modelAndView;
}
}
在jsp页面的开头第二行加
通过form提交给controller参数
action="${pageContext.request.contextPath}/Warehouse_Check_ProductShelfRelation.do"
method="post">
货架名
name="shel_name" >
货架位置
name="shel_loc">
查询
table遍历一个list并动态添加显示出的行
数量${requestScope.amount}status.index ${user.user_email}