Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does each dispatcher servlet know which controllers to check, in a multi-dispatcher application?

Background

I am new to spring and have been looking at how the dispatcher probes @controller annotated classes and methods.

Question

If you can have multiple dispatcher servlets in a single web application how do you assign them to specific controllers?

like image 526
Usman Mutawakil Avatar asked Feb 03 '26 01:02

Usman Mutawakil


1 Answers

Assuming Spring 3.x, you would configure each dispatcher with its own Spring configuration file (or class). Then (assuming an XML config) in one dispatcher, you would declare:

<context:component-scan base-package="com.acme.project.foo"/>

and in the other dispatcher you would do:

<context:component-scan base-package="com.acme.project.bar"/>

That way each dispatcher would be associated with different Controllers based on their package structure.

like image 184
nickdos Avatar answered Feb 04 '26 16:02

nickdos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!