同事写的代码 学到了 但是脑子记不住 特此记录
后台:
@RequestMapping(params = { "method=fun" })
protected ModelAndView fun(HttpServletRequest request) throws Exception {
List<model> codes = new ArrayList<model>();
try {
LoginUserVo userVo=getSessionLoginUser(request);
model code = xxBo.getXXCode(userVo.getCompanyId());
if(code==null||code.getIsProvincial().equals("Y")){
codes = cspBranchCityCodeBO.getAllCspBranchCityCodes();
}else{
codes.add(code);
}
} catch (Exception e) {
logger.error("获取公司信息出错",e);
}
request.setAttribute("companyList", codes);
return new ModelAndView("/ireportPages/xxx.jsp");
}
对应的jsp页面中:
<select id="companyId" name="companyId" class="easyui-combobox" style="width:160px;">
<option value=‘‘>全部</option>
<c:forEach items="${companyList}" var="c">
<option value=‘${c.code}‘>${c.name}</option>
</c:forEach>
</select>