springboot-angular-app-demo/src/main/java/org/gcube/app/springbootangulardemo/controller/GreetingController.java

23 lines
790 B
Java
Raw Normal View History

2020-03-06 15:35:36 +01:00
package org.gcube.app.springbootangulardemo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
2020-03-09 13:31:21 +01:00
import org.springframework.web.bind.annotation.RequestMethod;
2020-03-06 15:35:36 +01:00
import org.springframework.web.bind.annotation.RequestParam;
@Controller
2020-03-09 13:31:21 +01:00
@RequestMapping("/api")
//@ResponseBody
2020-03-06 15:35:36 +01:00
public class GreetingController {
//This return the templates/greeting.html
2020-03-09 13:31:21 +01:00
@RequestMapping(value = "/greeting", method = RequestMethod.GET, produces = {"text/html"})
2020-03-06 15:35:36 +01:00
public String greeting(@RequestParam(name="name", required=false, defaultValue="World") final String name,
final Model model) {
//This return the greeting.html
model.addAttribute("name", name);
return "greeting";
}
}