Java

James Clack
James Clack
4,840 Points

Capture a URI parameter objective

I have the written the following code for the objective, but it comes back with errors saying that it cannot locate the symbols at the @Autowired annotation or the contactController.findById(id) function. Can someone please explain to me what I have done wrong?

package com.teamtreehouse.contactmgr.controller;

import com.teamtreehouse.contactmgr.model.Contact;

import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.ui.ModelMap;

@Controller public class ContactController {

@Autowired
private ContactController contactController;

@RequestMapping("/")
public String home() {
  return "index";
}

@RequestMapping("/contact/8")
public String contact(@PathVariable int id, ModelMap modelMap) {
  Contact c = contactController.findById(id);
  modelMap.put("contact",c);
  return "contact_detail";
}

}