Results 1 to 2 of 2

Thread: @RequestMapping overriding

  1. #1
    Join Date
    Sep 2012
    Posts
    1

    Default @RequestMapping overriding

    Hello all!

    It's my first post at this forum, so I'd like to welcome everyone
    Currently we are developing kind-of addon/plugin functionality for our system based on Spring 3.1. One of its function would be the possibility to override existing controller with another one with the same request mapping. So for example we have:

    Code:
    @Controller
    @RequestMapping(value = "/login")
    public class LoginPageController extends AbstractLoginPageController
    {
    	@RequestMapping(method = RequestMethod.GET)
    	public String doLogin(final HttpServletRequest request, final HttpServletResponse response, final HttpSession session)
    	{
    		...
    	}
    }
    and in the addon we would like to have:

    Code:
    @Controller
    @RequestMapping(value = "/login")
    public class AddonLoginPageController
    {
    	@RequestMapping(method = RequestMethod.GET)
    	public String doLogin(final HttpServletRequest request, final HttpServletResponse response, final HttpSession session)
    	{
    		...
    	}
    }
    Is there any way to achieve it? Currently all my efforts ends with ambiguous mapping error:

    Code:
    ERROR [WrapperSimpleAppMain] [ContextLoader] Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestM
    appingHandlerMapping#0': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'de.h
    ybris.platform.addons.addtld.controllers.AddonLoginPageController#0' bean method
    public java.lang.String de.hybris.platform.addons.addtld.controllers.AddonLoginPageController.doLogin(java.lang.String,boolean,org.springframework.ui.
    Model,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpSession)
    to {[/login],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'loginPageController' bean method
    public java.lang.String de.hybris.platform.yacceleratorstorefront.controllers.pages.LoginPageController.doLogin(java.lang.String,boolean,org.springfra
    mework.ui.Model,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpSession) throws de.hybris.platform
    .cms2.exceptions.CMSItemNotFoundException mapped.
    I think one approach could be to override the mapping, another to override the actual controller bean, but have not succeeded yet
    Thanks in advance for any ideas!

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    As you already noticed with the default provided classes that isn't possible,you would have to create your own (sub)class for a HandlerMapping implementation.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •