Create MessageController.java

This commit is contained in:
Juan García Heredero 2016-08-01 10:42:00 +02:00 committed by GitHub
parent 067d99aaa5
commit 17166a5394
1 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,24 @@
package com.baeldung.web.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@RequestMapping("/message")
public class MessageController {
@RequestMapping(value = "/showForm", method = RequestMethod.GET)
public String showForm() {
return "message";
}
@RequestMapping(value = "/processForm", method = RequestMethod.POST)
public String processForm(@RequestParam("message") final String message, final Model model) {
model.addAttribute("message", message);
return "message";
}
}