Skip to content

Instantly share code, notes, and snippets.

@fuchodeveloper
Last active April 23, 2018 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fuchodeveloper/84176038b56beaaa4c33b0aaa5a7e63f to your computer and use it in GitHub Desktop.
Save fuchodeveloper/84176038b56beaaa4c33b0aaa5a7e63f to your computer and use it in GitHub Desktop.
Form controller file
package hello;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class HelloController {
@GetMapping("/hello")
public String helloForm(Model model) {
model.addAttribute("hello", new Hello());
return "hello";
}
@PostMapping("/hello")
public String helloSubmit(@ModelAttribute Hello hello) {
return "result";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment