Spring MVC 3: same @RequestMapping in different controllers, with centralised XML URL mapping (hybrid xml/annotations approach) -


i keep mapping in same place, use xml config:

<bean class="org.springframework.web.servlet.handler.simpleurlhandlermapping">      <property name="mappings">         <value>             /video/**=videocontrollerr             /blog/**=blogcontroller         </value>     </property>     <property name="alwaysusefullpath">         <value>true</value>     </property> </bean> 

if create second request mapping same name in different controller,

@controller public class blogcontroller {     @requestmapping(value = "/info", method = requestmethod.get)     public string info(@requestparam("t") string type) {         // stuff     } }  @controller public class videocontroller {     @requestmapping(value = "/info", method = requestmethod.get)     public string info() {         // stuff     } } 

i exception:

caused by: java.lang.illegalstateexception: cannot map handler 'videocontroller' url path [/info]: there handler of type [class com.cyc.cycbiz.controller.blogcontroller] mapped. 

is there way use same request mappings in different controllers?

i want have 2 urls as:

/video/info.html  /blog/info.html 

using spring mvc 3.1.1

edit: i' not one: https://spring.io/blog/2008/03/24/using-a-hybrid-annotations-xml-approach-for-request-mapping-in-spring-mvc

the rest of app works perfectly.

just put requestmapping @ level of controller also:

@controller @requestmapping("/video") public class videocontroller {     @requestmapping(value = "/info", method = requestmethod.get)     public string info() {         // stuff     } }  @controller @requestmapping("/blog") public class blogcontroller {     @requestmapping(value = "/info", method = requestmethod.get)     public string info(@requestparam("t") string type) {         // stuff     } } 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -