Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9216275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:23:00+00:00 2026-06-18T02:23:00+00:00

I perform refactoring and split controller into 2 controllers with: @RequestMapping(value = /graph.htm, method

  • 0

I perform refactoring and split controller into 2 controllers with:

@RequestMapping(value = "/graph.htm", method = RequestMethod.POST, params="first")

in first controller and:

@RequestMapping(value = "/graph.htm", method = RequestMethod.POST, params="second")

in second controller so these annotations lie in different files. When I build and use project all is fine (I put input HTML tag in my forms with different names: first and second).

But when I try to run JUnit controller test:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:test-context.xml" })

I get trace:

Caused by: java.lang.IllegalStateException: Cannot map handler 'firstController'
  to URL path [/graph.htm]: There is already handler
  of type [class com.web.controller.SecondController] mapped.
    at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:294)
    at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:266)
    at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:82)
    at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.initApplicationContext(AbstractDetectingUrlHandlerMapping.java:58)
    at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119)
    at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:72)
    at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
    at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:117)
    at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:92)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:399)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)

When I comment out this:

@RequestMapping(value = "/graph.htm", method = RequestMethod.POST, params="second")

in second controller individual test for first controller successfully completed.

To resolve this issue I may use different URLs (value in @RequestMapping) but I don’t understand why request mapping resolved for params in my production build of application and fail with SpringJUnit4ClassRunner.

Any help welcome!

PS. I use Spring 3.2.

PPS. I found mostly same issue Can I have the same mapping value with different param in a different Spring controller? but according to answers my production build also must fail?! But I run production build successfully!!

Also refer to:

  • @RequestMapping with 2 params in render method
  • Spring MVC 3: same @RequestMapping in different controllers, with centralised XML URL mapping (hybrid xml/annotations approach)

*PPS.

I check official docs for 3.2:

http://static.springsource.org/spring/docs/3.2.x/javadoc-api/org/springframework/web/bind/annotation/RequestMapping.html#params%28%29

In a Servlet environment, parameter mappings are considered as restrictions
that are enforced at the type level. The primary path mapping (i.e. the
specified URI value) still has to uniquely identify the target handler, with
parameter mappings simply expressing preconditions for invoking the handler.

So seems I perform illegal coding practice…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:23:01+00:00Added an answer on June 18, 2026 at 2:23 am

    My neighbour colleague help me with debugging issue.

    We compare production and test environment and found difference in context XML configuration.

    Previous test configuration which fail:

        <bean name="handlerMapping"
              class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
        <bean name="handlerAdapter"
              class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
    

    New and working test context configuration:

        <bean name="handlerMapping"
              class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
        <bean name="handlerAdapter"
              class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>
    

    Different spring classes use different mapping schema. Old uses per classes, newer uses per methods!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I perform a refactoring (extract variable for instance) in a .mxml file, IntelliJ
I read this question but the answer does not perform a refactoring of the
I have a method that is called on an object to perform some business
I perform some decoding process in the native code and call a Java method
I am refactoring an old installshield application and I need to perform a action
I'm looking around for a way to perform batch refactoring on a complete Java
Let's suppose I need to perform some average-length (several days) refactoring. I create mybranch
I am working on splitting code into smaller files and refactoring it a bit.
I am currently refactoring an application into multiple classes in an attempt to fulfill
I perform this kind of query in my Python code to conn = rdbms.connect(instance=_INSTANCE_NAME,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.