You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Tri Quan <qu...@wans.net> on 2014/06/23 23:06:27 UTC
need help using Struts2 - interator
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
Re: need help using Struts2 - interator
Posted by Lukasz Lenart <lu...@apache.org>.
2014-06-24 22:11 GMT+02:00 Tri Quan <qu...@wans.net>:
> I use Netbeans-7.0, Tomcat 2.2.3, JDK1.6 for development and use ant-deploy
> Per the perspective of Netbeans, iteratorkfc.jsp is under 'Web Pages'
> Project IteratorKFC has the following structure:
>
> InteratorKFC
> Web Pages
> META-INF
> WEB-INF
> iteratorkfc.jsp
> Source Pages
> Libraries
> Configuration Files
> Context.xml
> Struts.xml
> Web.xml
>
>
> Do you see any issue with location of iteratorkfc.jsp ?
>
> Error --> The requested resource (/IteratorKFC/IteratorKFC/iteratorkfc.jsp) is not available.
Yes, because it's under WebApp root so the path must be
/iteratorkfc.jsp
Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: need help using Struts2 - interator
Posted by Tri Quan <qu...@wans.net>.
I use Netbeans-7.0, Tomcat 2.2.3, JDK1.6 for development and use ant-deploy
Per the perspective of Netbeans, iteratorkfc.jsp is under 'Web Pages'
Project IteratorKFC has the following structure:
InteratorKFC
Web Pages
META-INF
WEB-INF
iteratorkfc.jsp
Source Pages
Libraries
Configuration Files
Context.xml
Struts.xml
Web.xml
Do you see any issue with location of iteratorkfc.jsp ?
Error --> The requested resource (/IteratorKFC/IteratorKFC/iteratorkfc.jsp) is not available.
Tri Quan
-----Original Message-----
From: Lukasz Lenart [mailto:lukaszlenart@apache.org]
Sent: Tuesday, June 24, 2014 3:18 AM
To: Struts Users Mailing List
Subject: Re: need help using Struts2 - interator
2014-06-23 23:06 GMT+02:00 Tri Quan <qu...@wans.net>:
> iteratorkfc.jsp file is in 'web' folder of the project. Its content
> listed
'web folder' means nothing, you cannot label folder web or js or css and expect it will be automagically selected as a folder with web content. It depends on build tool you are using, for Maven it is src/main/webapp, Eclipse uses WebContent as I can recall
Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: need help using Struts2 - interator
Posted by Lukasz Lenart <lu...@apache.org>.
2014-06-23 23:06 GMT+02:00 Tri Quan <qu...@wans.net>:
> iteratorkfc.jsp file is in 'web' folder of the project. Its content listed
'web folder' means nothing, you cannot label folder web or js or css
and expect it will be automagically selected as a folder with web
content. It depends on build tool you are using, for Maven it is
src/main/webapp, Eclipse uses WebContent as I can recall
Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org