我有以下内容:
@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;
}
}
然而,扩展控制器没有解决请求,但是当它们在基本控制器中时,它们已经解决得很好,我已经探到了几个线程但是找不到解决方案,任何想法?
答案 0 :(得分:2)
问题是您在向/admin/login
资源执行请求时能够获得响应,而不是/admin/customer/mapping
资源,除非您将customerMapping()
方法移动到{ {1}}上课?
解决方案是使用AdminController
注释注释AdminCustomerController
类。如果没有stereotype注释(以及适当的组件扫描),Spring将不会将该类识别为Spring bean。