How to write 2 controllers in spring MVC -


Is it possible that 2 controllers such as DispatherServet in Spring MVC write more than one time when we develop spring MVC applications Are there.

Yes .. !! it's possible. You must set a @RequestMapping annotation at the class level, the value of that annotation will be the prefix of all the requests that come with that controller.

Example:

For 1 admin: @controller @ request mailing ("test") public class test controller {} < / Code>

For the second controller:

  @Controller @RequestMapping ("demo") public class DemoController {}  

If there are different / different methods of the two controllers, then you can reach

  & lt; Your server & gt; / Test / & lt; Request Method Mapping & gt; & Lt; Your server & gt; / Demo / & lt; Request Method Mapping & gt;  

Comments

Popular posts from this blog

jsp - No mapping found for HTTP request with URI with annotation config Spring MVC and Jetty -

java - Ajax call to jsp and jsp redirecting to further jsp -

c# - Roxy file manager in MVC doesn't accept session path -