Skip to content

Instantly share code, notes, and snippets.

@hseritt
Created June 27, 2016 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hseritt/7058af370eca358e47a581dbd017fe92 to your computer and use it in GitHub Desktop.
Save hseritt/7058af370eca358e47a581dbd017fe92 to your computer and use it in GitHub Desktop.
Spring MVC controller
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/")
public class Start {
private StartPageProperties startPageProps;
private AgentRepository agentRepository;
@Autowired
public Start(StartPageProperties startPageProps, AgentRepository agentRepository) {
this.startPageProps = startPageProps;
this.agentRepository = agentRepository;
}
@RequestMapping(value="/", method=RequestMethod.GET)
public String getIndex(Model model) {
String templateFile = startPageProps.getTemplateFolder() + "/index";
model.addAttribute("pageTitle", startPageProps.getPageTitle());
model.addAttribute("appName", startPageProps.getAppName());
model.addAttribute("agents", agentRepository.findByActive(true));
return templateFile;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment