views:

4301

answers:

3

Hi there,

I am new to strut/web programming and I thought I could learn alot by reading a sample app.

On google, I searched and found a sample app at

http://www.roseindia.net/struts/struts2/struts2tutorial.zip The tutorial is really nice and it gives a sample login page.

However, I couldn't run this sample app. I tried posting on the roseindia.net site and got no help either.

There is no error logged during the start of the server,

but when I try and open one of the helloworld's link the following is outputted

I am getting this error

SEVERE: Could not find action or result
There is no Action mapped for action name HelloWorld. - [unknown location]

The folder structure of this thing on my eclipse is

/WebContent/WEB-INF/java/net/roseindia/Struts2HelloWorld.java

/WebContent/pages/HelloWorld.jsp

/WebContent/WEB-INF/struts.xml

while in strut.xml the sample had..

    <action name="HelloWorld" class="net.roseindia.Struts2HelloWorld">
        <result>/pages/HelloWorld.jsp</result>
    </action>

I am suspecting something in the strut.xml is wrong?

I am using eclipse J2EE and tomcat6

I have already tried posting on roseindia's site and got no help.

+1  A: 

You will learn a lot by reading sample apps. If your sample doesn't work, perhaps your sample is wrong.

Perhaps you need the actual authoritative documentation. See How to setup a basic struts project using Eclipse. This is the as official as any Eclipse - Struts documentation can be.

Perhaps you need a better example. See the Struts Community Projects and Examples web site for numerous examples.

S.Lott
A: 

Did you name the file "strut.xml" or "struts.xml"? It should be the latter (although you could override it if you wanted). Also, in Struts 2 the struts.xml file has to be in the classpath, not at the root of WEB-INF. So, in your project, you should put in the "src" folder, so when it deploys it goes into WEB-INF/classes. You can verify it goes into the correct place by doing an "Export" of the web application to a WAR file and verifying it went into WEB-INF/classes.

David M. Karr
A: 

I've just downloaded a copy of this tutorial, and deployed it to Tomcat 6 - and it works!

Perhaps they have fixed the bug since you last tried? Or perhaps there's something wrong with the way you have Eclipse configured.

Al I did was to unzip the tutorial; copy the directory into the Tomcat webapps directory; start Tomcat; navigate to the Tomcat manager page on my PC; and click the link to the struts2tutorial application.

Give it another try...

sgreeve