• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Strunts 2.1.6 - Error mapping action when using Annotations

 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

there are millions of threads that treat the action mapping issue, but none gives me the information I need.

Working through the Manning Struts2InAction book, I have set up the HelloWorld program using the XML configuration mode.

Now with annotations it gets me stuck. First, the book works with Struts 2.0.x, the Result annotation has been moved to another jar and also follows another syntax.
When I used the jars the book uses too, the book example does what it's supposed to.

Now, using the latest struts version, the annotation arguments have changed. There is no value element anymore to trigger the view. I guess it has simply been replaced by the location attribute.
The more confusing part is that the name attribute is now mandatory. What about pass-through actions. The way I implemented it right now was by giving the annotation a name of SUCCESS, and make the execute() function return "SUCCESS".

The java file is called manning.chapterTwo.AnnotatedNameCollector. This is the full class code.



The web.xml contains the 'actionPackages' init param for the FilterDispatcher with value 'manning', the struts.xml contains nothing but the devMode=true constant.

now, upon navigating to http://localhost:8080/Struts2InAction/chapterTwo/annotatedNameCollector.action it gives me this ...


I don't know what they changed with the latest version of Struts2, but I'm stuck.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't treat Convention the same as Codebehind: they're different.

Did you read the wiki docs for S2.0-S2.1 conversions or the Convention plugin docs regarding switching from Codebehind to Convention?
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have just read http://cwiki.apache.org/WW/converting-application-from-codebehind-to-convention-plugin.html ...

even after I changed http://localhost:8080/Struts2InAction/chapterTwo/annotatedNameCollector.action

to http://localhost:8080/Struts2InAction/chapterTwo/annotated-name-collector.action , which seemed to be the only difference, I get the same mapping exception.
 
Poop goes in a willow feeder. Wipe with this tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!