[ 
https://issues.apache.org/struts/browse/WW-2515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43406#action_43406
 ] 

Jeromy Evans commented on WW-2515:
----------------------------------

I agree checking for a null model is a simple solution, but:
  - is it really appropriate to return a 404 even though the action may have 
executed?
  - this solution doesn't work for non-ModelDriven controllers as the target 
(action) is always non-null
  - accessing a resource that doesn't exist (eg. the action doesn't exist) 
still throws an exception instead of a 404

I expect the solution should be combined with the one that generates a 405 
"method not supported" where the action doesn't have the corresponding method 
(currently throws a method not found exception).  This may be best handled by 
default exception handlers but I'm not sure.


> REST plugin does not throw a 404 if resource cannot be found
> ------------------------------------------------------------
>
>                 Key: WW-2515
>                 URL: https://issues.apache.org/struts/browse/WW-2515
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - REST
>    Affects Versions: 2.1.1
>         Environment: Struts 2.1.1-SNAPSHOT using Jetty 6.1.5
>            Reporter: Sarat Pediredla
>         Attachments: WW-2515.patch
>
>
> When there is a GET request for a resource that does not exist, example GET 
> /authors/25 where author with id 25 does not exist, the getModel() method of 
> the action should return null (and in most cases will return null as the 
> object does not exist).
> However, the current ContentTypeInterceptor implementation is not entirely 
> RESTful as the right response should be HTTP Status Code 404 "Not Found".
> I have patched the ContentTypeInterceptor to return a 404 status if the 
> requested resource could not be found.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to