Announcement Announcement Module
Collapse
No announcement yet.
MVC annotations on Controller interface Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MVC annotations on Controller interface

    Hi,

    I have a situation when REST server side should expose MVC contoller interface, so that REST client side will be able to generate proxy stab (by investigating interface annotations) and send REST requests via restTemplate. Something that we gets for free in JBoss RestEasy framework and unfortunately still does not exist in Spring.

    The issues that I'm facing is that not all MVC annotations are inherited by controller from its' interface and some of them should be duplicated with some restrictions.

    Code:
    public interface MapController {
    	
    	@RequestMapping(value="/tree/{parent}", method=RequestMethod.GET)
    	public @ResponseBody List<Node> getMapTree(@PathVariable(value="parent") String parent);
    	
    }
    
    @Controller
    @Scope(value=WebApplicationContext.SCOPE_REQUEST)
    public class MapControllerImpl implements MapController {
    
    	@Override
    	public List<Node> getMapTree(@PathVariable String parent) {
    
    		return mapService.getMapTree(parent);
    	}
    }
    Problems:
    1) If I remove @PathVariable from MapCotrollerImpl method, the mapping does not work, I get always null in parent.
    2) If I change the parent parameter name in MapControllerImpl method, so that the name of the parameter name is not the same as in @PathVariable(value="parent") , it does not work.

    So, fist of all I'm trying to understand why so basic things do not work ? Is it a bug ?

    And if there is any workaround ?

    Thanks,
    Pavel
Working...
X