1

我有以下内容:

@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;
    }
}

但是,扩展控制器不解决请求,但是当它们在基本控制器中时,它们被解决得很好,我已经浏览了几个线程但找不到解决方案,知道吗?

4

1 回答 1

2

除非您将方法移至类,否则在执行对/admin/login资源的请求而不是对资源的请求时,您是否能够获得响应?/admin/customer/mappingcustomerMapping()AdminController

解决方案是使用注解对AdminCustomerController类进行@Controller注解。如果没有构造型注释(和适当的组件扫描),Spring 将不会将该类识别为 Spring bean。

于 2013-01-27T10:01:23.200 回答