struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tri Quan" <quans...@wans.net>
Subject need help on struts.xml configuration using Struts 2.3, Tomcat 7, Java JDK 1.6
Date Fri, 20 Jun 2014 11:33:03 GMT
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 ?

 

Struts has detected an unhandled exception: 

There is no Action mapped for namespace / and action name menu. - [unknown
location]

com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:1
89)

 
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)

 
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsAct
ionProxyFactory.java:39)

 
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultA
ctionProxyFactory.java:58)

 
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)

 
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.jav
a:434)

 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:243)

 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:210)

 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:240)

 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:164)

 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:462)

 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
)

 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100
)

 
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)

 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:118)

 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403)

 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:301)

 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:162)

 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:140)

 
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:
309)

    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    java.lang.Thread.run(Unknown Source)

    

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>

	
 

 

 

Thank you for your help and advices. 

Tri Quan


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message