我正在尝试显示一个列表。但什么都没有显示。我使用了本教程: http ://www.roseindia.net/struts/struts2/struts2controltags/iterator-tag.shtml
但实际上它不起作用
有人在本教程中看到错误吗?
编辑:
那就是 ShowKeywords.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<title>Iterator Tag Example!</title>
</head>
<body>
<h1><span style="background-color: #FFFFcc">Iterator Tag Example!</span></h1>
<s:iterator value="myList" status="myListStatus">
<s:property /><br>
</s:iterator>
</body>
</html>
Struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<!-- mapping of global-results and global-exceptions -->
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
<constant name="struts.devMode" value="false"/>
<package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<default-action-ref name="Start"/>
<action name="ShowTest" class="de.nordakademie.librarymgmt.action.ShowTest">
<result>showKeywords</result>
</action>
</package>
</package>
</struts>
瓷砖
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="main" template="/jsp/main.jsp">
<put-attribute name="title" value="Dashboard"/>
<put-attribute name="menu" value="/jsp/menu.jsp"/>
<put-attribute name="header" value="/jsp/header.jsp"/>
<put-attribute name="content" value="/jsp/start.jsp"/>
</definition>
<definition name="showKeywords" extends="main">
<put-attribute name="title" value="Stichworte anzeigen"/>
<put-attribute name="content" value="/jsp/ShowKeywords.jsp"/>
</definition>
</tiles-definitions>
动作展示测试
package de.nordakademie.librarymgmt.action;
import com.opensymphony.xwork2.ActionSupport;
import java.util.*;
public class ShowTest extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
private List<String> myList;
public String execute()throws Exception{
myList = new ArrayList<String>();
myList.add("Fruits");
myList.add("Apple");
myList.add("Mango");
myList.add("Orange");
myList.add("Pine Apple");
return SUCCESS;
}
public List<String> getMyList(){
return myList;
}
}