EL表达式语言的问题
jsp 页面:
<td> <select name= "module " id= "module ">
<c:forEach items= "${options} " var= "option ">
<option value= "${option.id} "> ${option.name} </option>
</c:forEach>
</select> </td>
后台:
public ModelAndView getData(HttpServletRequest request,
HttpServletResponse response) {
List <BusinessModule> bizList=bizModuleSvc.getAll();
Iterator <BusinessModule> it = bizList.iterator();
ArrayList <SelectOption> options = new ArrayList <SelectOption> ();
SelectOption option ;
while (it.hasNext()) {
BusinessModule element = (BusinessModule) it.next();
option = new SelectOption();
option.setId(element.getId());
option.setName(element.getModuleName());
options.add(option);
}
request.setAttribute( "options ", options);//保存模块名称
return new ModelAndView(getBizTask_view());
}
数据为何就是显不出来??
显示的还是${option.name}而不是数据?
------解决方案--------------------2.4以上的Web应用在默认情况下EL才是打开的。其他的都要设置才行。
web.xml文件中把应用的版本改成2.4就行了。像下面这个样子:
<?xml version= "1.0 " encoding= "UTF-8 "?>
<web-app id= "WebApp_ID " version= "2.4 " xmlns= "http://java.sun.com/xml/ns/j2ee "
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance "
xsi:schemaLocation= "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
……
------解决方案--------------------解决的好快呀.