You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
781 B
23 lines
781 B
4 years ago
|
package MTGClone.controller;
|
||
|
|
||
|
import org.springframework.stereotype.Controller;
|
||
|
import org.springframework.ui.Model;
|
||
|
import org.springframework.ui.ModelMap;
|
||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||
|
|
||
|
@Controller
|
||
|
public class HelloController {
|
||
|
@GetMapping({"/", "/hello"})
|
||
|
public String hello(Model model, @RequestParam(value="name", required=false, defaultValue="World") String name) {
|
||
|
model.addAttribute("name", name);
|
||
|
return "hello";
|
||
|
}
|
||
|
|
||
|
@PostMapping({"/greet"})
|
||
|
public String greet(@RequestParam("name") String name, ModelMap modelMap) {
|
||
|
modelMap.put("name", name);
|
||
|
return "hello";
|
||
|
}
|
||
|
}
|