aspose file tools*
The moose likes Struts and the fly likes Struts2 Annotations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 Annotations" Watch "Struts2 Annotations" New topic
Author

Struts2 Annotations

Peter Mest
Ranch Hand

Joined: Aug 14, 2009
Posts: 30
I'm trying to implement the Struts 2 Annotations in my project, but I don't know how.

I added the convention-plugin to my pom



I modified the web.xml like this:



But when I add the @Result annotation, the IDE tells me:




What I'm doing wrong?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Using a "value" annotation parameter, of which there isn't one. Do you mean "location"?

See the Result annotation documentation.
Peter Mest
Ranch Hand

Joined: Aug 14, 2009
Posts: 30
David Newton wrote:Using a "value" annotation parameter, of which there isn't one. Do you mean "location"?

See the Result annotation documentation.


The first time I tried with location and it didn't work and I saw "value" in a Struts 2 book (??) and I thought this is the reason why is not working.


Anw, I retried the same setup and doesn't work. When I press the link associated to the action helloWorld (I have a class HelloWorld which extends ActionSupport, its sends me to the exactly the same page. So, from index.jsp, it's sends to index.jsp.

I uploaded the project (a simple HelloWorld app) to FileFront, maybe someone sees where is the problem.
http://www.filefront.com/16364385/Hello_World.zip
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Just post the code; how long can it be?!
Peter Mest
Ranch Hand

Joined: Aug 14, 2009
Posts: 30
Ok.

web.xml



index.jsp



HelloWorld.java



David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And what's the problem? That doesn't look like what you had posted originally.

Note that Action.SUCCESS is *not* "SUCCESS", but rather "success".
Peter Mest
Ranch Hand

Joined: Aug 14, 2009
Posts: 30
David Newton wrote:And what's the problem? That doesn't look like what you had posted originally.

Note that Action.SUCCESS is *not* "SUCCESS", but rather "success".


Ok. I changed that. Anw, I don't see any difference for the moment. :)

I commented the package section from struts.xml and now I receive:
# Messages:
There is no Action mapped for namespace / and action name helloWorld.

So

If in my struts.xml I have this code:


I get the behaviour from the 3rd post.
So, from index.jsp, it's sends back to index.jsp. It should send me to HelloWorld.jsp


If I comment the package section I receive

There is no Action mapped for namespace / and action name helloWorld.
Peter Mest
Ranch Hand

Joined: Aug 14, 2009
Posts: 30
No more suggestions? :cry:
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Turn up the log level to DEBUG and check out how it's scanning: you'll find there are a couple of issues.

You can also use the config-browser to help track stuff like this down--it will tell you what S2 believes your configuration to be (including convention-based actions). Read the convention plugin documentation page very carefully, paying attention in particular to the parameters it provides, and their defaults. It is not always doing what I think you believe it is.

Also, be cautious about using package names that aren't yours.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 Annotations
 
Similar Threads
Richfaces + Spring + Maven Setup help
Maven web project dependencies
Maven dependencies
Spring Major version '3' expected
Maven + Tiles + Struts2