一、当一个jsp页面请求某个action,servlet将数据再转发到该jsp页面并跳转到该页面,而该jsp页面中有下拉框,那么下拉框的值如何取到呢?
1.首先该jsp页面中要引入数据表格插件:
jquery.dataTables.min.js和dataTables.bootstrap.min.js
前提是要引入jquery插件,如jquery-1.9.1.min.js,以上插件才能用
2.参考下面代码:
//handle.jsp页面
<div class="form-group">
<label for="Seed_Bill_Icon">物品流动性质</label> <select
class="form-control" id="Seed_Bill_Property"
name="seed_bill_property">
<option value="">--请选择</option>
<c:forEach items="${gproperty}" var="item">
<option value="${item.dict_id}"
<c:if test="${item.dict_id==g_property}">selected</c:if>>
${item.dict_item_name}
</option>
</c:forEach>
</select>
</div>
注意g_property是POJO封装的属性!
点击请求action,完全可以不带参数。
可以在跳转页面之前重定向action,后台代码如下:
@RequestMapping(value="/priceaudit/seed_bill_handle.action")
public String seedbillhandle(@RequestParam(defaultValue="1")Integer page, @RequestParam(defaultValue="10")Integer rows,Integer g_ref_id,String g_name,String g_type, String g_cite_id,String g_details,Float g_singleprice,Model model) {
Page<Good> goods = goodService.findGoodSeedList(page, rows, g_ref_id, g_name, g_type, g_cite_id, g_details,g_singleprice);
model.addAttribute("good_page", goods);
//查找t_dict中的对应项
List<BaseDict> gproperty= baseDictService.findBaseDictByTypeCode(G_PROPERTY);
model.addAttribute("gproperty", gproperty);
return "handle";
}