我jsp页面中下拉列表中option嵌套了<c:if>,
页面中能显示,但是Servlet中接收的值始终是null,
找问题找了很久感觉应该是传参出了问题,
但是不知道具体出在哪
感激不尽
jsp中:
<form method="get" action="SelectBillServlet">
<input name="method" value="query" class="input-text" type="hidden">
<span>商品名称:</span>
<input name="queryProductName" type="text" value="${queryProductName }">
<span>供应商:</span>
<select name="queryProviderId">
<c:if test="${requestScope.providerList != null }">
<option value="0">--请选择--</option>
<c:forEach var="provider" items="${requestScope.providerList}">
<option <c:if test="${provider.id == queryProviderId }">selected="selected"</c:if>
value="${provider.id}">${provider.proName}</option>
</c:forEach>
</c:if>
</select>
<span>是否付款:</span>
<select name="queryIsPayment">
<option value="0">--请选择--</option>
<option value="1" ${queryIsPayment == 1 ? "selected=\"selected\"":"" }>未付款</option>
<option value="2" ${queryIsPayment == 2 ? "selected=\"selected\"":"" }>已付款</option>
</select>
<input value="查 询" type="submit" id="searchbutton">
<a href="${pageContext.request.contextPath }/jsp/billadd.jsp">添加订单</a>
</form>
Servlet中:
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//获得供应商集合
ProviderService providerService = new ProviderServiceImpl();
List<Provider> providerList = providerService.getProviders();
req.setAttribute("providerList",providerList);
System.out.println(providerList.size());
//获得商品订单集合
String productName = req.getParameter("queryProductName");
Integer providerId = Integer.getInteger(req.getParameter("queryProviderId"));
Integer isPayment = Integer.getInteger(req.getParameter("queryIsPayment"));
System.out.println("商品名称:" + productName + "\t供应商:" + providerId + "\t是否付款:" + isPayment);
BillService bs = new BilServiceImpl();
List<Bill> bis = bs.selectBill(productName,providerId,isPayment);
req.setAttribute("bis",bis);
// req.setAttribute("queryProductName", productName);
// req.setAttribute("queryProviderId", providerId);
// req.setAttribute("queryIsPayment", isPayment);
req.getRequestDispatcher("jsp/billlist.jsp").forward(req,resp);
}