Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Strunts 2.1.6 - Error mapping action when using Annotations

 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic