日期:2014-05-18  浏览次数:20853 次

求教!<s:iterator>无法显示出来的问题!
我想做一个目录,使用的是在网页的一部分使用一个action,让后返回的页面在该部分显示(该页面就是一个简单的列表页li)。但是列表却怎么样都没办法显示出来。。。

控制台中可以列出目录的列表项,可见service和dao没有问题。应该就是structs标签写错的原因。可是我试了别的比如说#catalog.getCatalogname()的形式但是都不行。麻烦各位看看!本来突然发现忘记加taglib声明,但是加了也是没用。试了随便打一个数在menu,在catalogPage.jsp是可以显示的。

我的DishAction.java
package org.action;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.model.Catalog;
import org.model.Dish;
import org.service.ICatalogService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class DishAction extends ActionSupport
{
protected ICatalogService catalogService;
public void setCatalogService(ICatalogService catalogService)
{
this.catalogService = catalogService;

public String browseCatalog() throws Exception
{
List catalogs=catalogService.getAllCatalogs();
Map request=(Map)ActionContext.getContext().get("request");
request.put("catalogs", catalogs);

//在控制台列出所有的项
Iterator<Catalog> iterator=catalogs.iterator();
while(iterator.hasNext())
{
Catalog C=iterator.next();
System.out.println(C.getCatalogid()+C.getCatalogname());
}

return SUCCESS;
}

}

每次刷新jsp的时候都是有结果的


catalogPage.jsp(主界面  部分代码)
有加声明<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>



<nav class="left-sb-menu">
       <div class="left-sb-menu-title"><strong>菜品分类</strong></div>
        <s:action name="browseCatalog" executeResult="true"></s:action><
/nav>


menu.jsp
<%@ page contentType="text/html;charset=gb2312"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
        <link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta charset="utf-8">
        <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
        <title>menu</title>
        <link rel="stylesheet" href="css/style.css" media="screen">