You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Łukasz Lenart <lu...@gmail.com> on 2014/06/20 08:04:18 UTC
Re: need help on struts.xml configuration using Struts 2.3, Tomcat 7,
Java JDK 1.6
Attachment is missing and mailing doesn't allow to send attachments ;-)
2014-06-20 3:26 GMT+02:00 Tri Quan <qu...@wans.net>:
>
>
> All,
>
> I am green horn in Struts 2 and need help with
> struts.xml. I got the following error when try this URL :
>
> localhost:8080/IteratorKFC/menu or localhost:8080/IteratorKFC/menu.action
> .
>
>
>
>
>
> what is wrong ? Incorrect configuration or incorrect URL ?
>
>
>
>
>
> Thank you for your help and advices.
>
>
>
>
>
>
>
>
>
> Strut.xml source ========================================
>
> <?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">pages/iteratorkfc.jsp</result>
>
> </action>
>
> </package>
>
> </struts>
>
>
>
> ItertorKFCAction java ==========================================
>
> package iteratorkfc;
>
> import java.util.*;
>
>
>
> import com.opensymphony.xwork2.ActionSupport;
>
> 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;
>
> }
>
>
>
> }
>
>
>
> Jsp ============================================
>
> <%@ 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>
>
>
>
> Tri Quan
>
--
Łukasz
mobile +48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/