I have the following:
@Controller
@RequestMapping("/admin")
public class AdminController extends BaseHtmlController{
@Autowired
protected DeviceCustomerMap deviceCustomerMap;
@Autowired
protected CustomerDao customerDao;
String layout = "template/admin";
@RequestMapping(value="/login", method = RequestMethod.GET)
public String login(ModelMap model) {
model.addAttribute("meta", meta);
String view = "login";
return view;
}
}
public class AdminCustomerController extends AdminController{
@RequestMapping(value="/customer/mapping", method = RequestMethod.GET)
public String customerMapping(ModelMap model, @RequestParam(required=false) boolean refresh) throws Exception {
if (refresh){
deviceCustomerMap.initCustomerUrlMap();
}
model.addAttribute("meta", meta);
model.addAttribute("view", "customer/mapping");
model.addAttribute("customers", deviceCustomerMap.getCustomerMap());
return layout;
}
}
However, the extended controller doesn't resolve the requests, but when they're in the base controller, they're resolved just fine, I've poked around several threads but couldn't find a solution, any idea?
Is the problem that you are able to get a response when executing a request to the /admin/login
resource, but not to /admin/customer/mapping
resource, unless you move the customerMapping()
method to the AdminController
class?
The solution is to annotate the AdminCustomerController
class with the @Controller
annotation. Without a stereotype annotation (and appropriate component scanning), Spring will not recognise the class as a Spring bean.