struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rakeshxp <rakes...@gmail.com>
Subject Re: Struts 2 + Rest URLs
Date Wed, 27 Aug 2008 13:05:28 GMT

Excellent. Thanks! So now, I have the following
com.struts.example.action.AccountController 
com.struts.example.action.account.LogoutController

When I hit, http://localhost:8080/myapp/account/logout , then I get the
following exception
 No result defined for action
com.struts.example.action.account.LogoutController and result index
The LogoutController looks like this:
 public HttpHeaders index() {
        return new DefaultHttpHeaders("index").disableCaching();
    }

I have a logout-index.jsp directly under the webapp folder ( along with
account-show.jsp, help-show.jsp etc ). So is it the proper name structure ?
Also, 

1) How to specify the location of the JSPs ?  
           I wanted to have custom folders like this 
           i18n/en_US/help/index.jsp
           i18n/en_US/help/show.jsp
           i18n/en_US/account/show.jsp
           i18n/en_US/account/logout.jsp etc 
So that I can problematically serve the appropriate locale JSPs ( When using
struts 2.0.10, in the action XML, I was using something like this <result
name="success">/jsp/i18n/${userLocale}/account/show.jsp</result> )

2) The reason I wanted /<displayname> is something like this 
http://localhost/myapp/help -> help pages
.... some more static pages
anything which does not match the above, could potentially be a profile page
which has the url http://localhost/myapp/username. So I wanted something
like catch all , so that I can check if it happens to be a username.

3) Just curious, when running the above code, while tomcat was starting, I
was getting 
class:class com.struts.example.action.AccountController parent:null
current:com.struts.example.action.
class:class com.struts.example.action.account.LogoutController parent:null
current:com.struts.example.action.account

what does parent property mean ? 

Thanks!                  


Jeromy Evans - Blue Sky Minds wrote:
> 
> 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-%2B-Rest-URLs-tp19179856p19180492.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message