Create Spring web app.

source: http://www.programcreek.com/2014/02/spring-mvc-helloworld-using-maven-in-eclipse/
This commit is contained in:
Camille31
2016-11-13 18:37:26 +01:00
parent 0e1c54c60a
commit b1dd0dd0bb
6 changed files with 153 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package com.camillepradel.movierecommender.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class MainController {
String message = "Welcome to Spring MVC!";
@RequestMapping("/hello")
public ModelAndView showMessage(
@RequestParam(value = "name", required = false, defaultValue = "World") String name) {
System.out.println("in controller");
ModelAndView mv = new ModelAndView("helloworld");
mv.addObject("message", message);
mv.addObject("name", name);
return mv;
}
}