All,

 

I use Struts2 version 2.3, Tomcat 7, Java JDK 1.6, NetBeans 7.0  in learning
Iterator of Struts.

 

url : http://localhost:8080/IteratorKFC/IteratorKFC/menu.action  

receives Struts error : 

The requested resource (/IteratorKFC/IteratorKFC/iteratorkfc.jsp) is not
available.

 

 

Could you help and advise ?  Thanks

 

iteratorkfc.jsp file is in 'web' folder of the project. Its content listed
below =  =   =  =  =  =  =

<%@ page contentType="text/html; charset=UTF-8" %>

<%@ taglib prefix="s" uri="/struts-tags" %>

 

<html>

    <head>

        <title><s:text name="Struts2 Iterator "/></title>

    </head>

 

<body>

   <h1>Struts 2 Iterator tag example</h1>

   <h3>Simple Iterator</h3>

    <ol>

        <s:iterator value="comboMeals">

            <li><s:property /></li>

        </s:iterator>

    </ol>

  <h3>Iterator with IteratorStatus</h3>

    <table>

    <s:iterator value="comboMeals" status="comboMealsStatus">

        <tr>

            <s:if test="#comboMealsStatus.even == true">

                <td style="background: #CCCCCC"><s:property/></td>

            </s:if>

            <s:elseif test="#comboMealsStatus.first == true">

                <td><s:property/> (This is first value) </td>

            </s:elseif>

            <s:else>

                <td><s:property/></td>

            </s:else>

        </tr>

    </s:iterator>

    </table>

</body>

</html>

 

 

Context.xml  file listed below  =  =  =  =  =  = = = = = = =

<?xml version="1.0" encoding="UTF-8"?>

<Context antiJARLocking="true" path="/IteratorKFC"/>

 

 

Struts.xml  file listed below =  =  =  =  =  = = = = = = =

<?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";>

 

<struts>

    

    <!-- Configuration for the default package. -->

   <!-- <constant name="struts.action.extension" value=""/>  -->

      

    <constant name="struts.devMode" value="true" />

    <package name="IteratorKFC" namespace="/IteratorKFC"
extends="struts-default">

        <action name="menu" class="iteratorkfc.IteratorKFCAction"
method="execute">

                                <result
name="success">iteratorkfc.jsp</result>

                </action>

    </package>

</struts>

 

 

IteratorKFCAction  java clasee =   =   =   =  =  =  =  =  =  =  =  =  =  =

package iteratorkfc;

import java.util.*;

import com.opensymphony.xwork2.ActionSupport;

/**

*

* @author tquan

*/

public class IteratorKFCAction extends ActionSupport{

    private List<String> comboMeals;

                public List<String> getComboMeals() {

                                return comboMeals;

                }

                public void setComboMeals(List<String> comboMeals) {

                                this.comboMeals = comboMeals;

                }

    @Override

                public String execute() {

                                comboMeals = new ArrayList<String>();

                                comboMeals.add("Snack Plate");

                                comboMeals.add("Dinner Plate");

                                comboMeals.add("Colonel Chicken Rice
Combo");

                                comboMeals.add("Colonel Burger");

                                comboMeals.add("O.R. Fillet Burger");

                                comboMeals.add("Zinger Burger");

                                return SUCCESS;

                }

    

}

 

 

Tri Quan

Reply via email to