rakeshxp wrote:
Hi All,

I am migrating from struts 2.0.10 to 2.1.2 ( for need of restful URLs).
Could someone help me understand the following ?

1) Is it better to use Annotations or Codebehind for Restful URLs? ( I some
how like the annotations more than assuming some standard for resources)


This is a approach is fine. The annotations are a feature of CodeBehind in 2.1 (used by CodeBehind to create the configuration) Note that CodeBehind will be replaced by the ConventionPlugin in 2.2ish but the annotations won't need to change (much...).

2) I am stuck at running the restful URLs using codebehind plugin. Here are
the details: In web.xml, I have actionPackages = com.struts.example.action
and I have the following package struture:
    com.struts.example.action -> No files
com.struts.example.action.account -> AccountController com.struts.example.action.help -> HelpController expecting that, I will get the following URLs:
    http://localhost:8080/myapp/account

Close, but not quite right. It works like this:
com.struts.example.action.AccountController will be at http://localhost:8080/myapp/account com.struts.example.action.account.AccountController will be at http://localhost:8080/myapp/account/account

    http://localhost:8080/myapp/help

But this does not work. Could someone help me in figure out what is
happening ? Going forward, I wanted URLs of the following format
http://localhost:8080/myapp/account
http://localhost:8080/myapp/account/logout
http://localhost:8080/myapp/help
http://localhost:8080/myapp/<displayname>  ( so if it is not account or
help, then it would be a displayname and hence I want to process it
specifically ).

CodeBehind itself doesn't include any support for index actions, so you have to set this as follows:

com.struts.example.action.AccountController -> http://localhost:8080/myapp/account com.struts.example.action.account.LogoutController -> http://localhost:8080/myapp/account/logout com.struts.example.action.HelpController -> http://localhost:8080/myapp/help

Not sure what you mean with display need.  You probably need this:

com.struts.example.action.DisplayController -> http://localhost:8080/myapp/display/<displayname>

Where <displayname> will be set as an ID for the DisplayController
Otherwise you'll need to customize the actionmapper a little.

Hope that helps.




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to