c:foreach语句在JSP页面获取不到值,页面只显示EL表达 请高手帮忙解答一下,谢谢。 10
JSP页面中的代码<selectname="goods.cid"><optionselected>---请选择---</option><c:forEachvar="c"i...
JSP页面中的代码
<select name="goods.cid">
<option selected>---请选择---</option>
<c:forEach var="c" items="${cg}"><option value="${c.id}">${c.name}</option></c:forEach>
</select>
Javabean中的代码
private int id;
private String name;
private int count;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
数据库中已经添加过值了 但是就是不显示
Action中的代码
public String getForAdd()throws Exception{
ActionContext context = ActionContext.getContext();
Map req=(Map)context.get("request");
req.put("cg",categoryService.getCgForAdd());
return this.SUCCESS;
Dao层的代码
public List getCategForAdd(){
final List<Category> cg =new ArrayList<Category>();
String sql="select * from category";
jt.query(sql,new RowCallbackHandler(){
public void processRow(ResultSet rs) throws SQLException {
// TODO Auto-generated method stub
Category cag = new Category();
cag.setId(rs.getInt("c_id"));
cag.setName(rs.getString("category"));
cg.add(cag);
} 展开
<select name="goods.cid">
<option selected>---请选择---</option>
<c:forEach var="c" items="${cg}"><option value="${c.id}">${c.name}</option></c:forEach>
</select>
Javabean中的代码
private int id;
private String name;
private int count;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
数据库中已经添加过值了 但是就是不显示
Action中的代码
public String getForAdd()throws Exception{
ActionContext context = ActionContext.getContext();
Map req=(Map)context.get("request");
req.put("cg",categoryService.getCgForAdd());
return this.SUCCESS;
Dao层的代码
public List getCategForAdd(){
final List<Category> cg =new ArrayList<Category>();
String sql="select * from category";
jt.query(sql,new RowCallbackHandler(){
public void processRow(ResultSet rs) throws SQLException {
// TODO Auto-generated method stub
Category cag = new Category();
cag.setId(rs.getInt("c_id"));
cag.setName(rs.getString("category"));
cg.add(cag);
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询