Created
June 27, 2016 01:57
-
-
Save hseritt/7058af370eca358e47a581dbd017fe92 to your computer and use it in GitHub Desktop.
Spring MVC controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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