首页
学习
活动
专区
圈层
工具
发布
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    Spring认证指南:了解如何使用 Spring 创建和提交 Web 表单

    单击Dependencies并选择Spring Web和Thymeleaf。 单击生成。 下载生成的 ZIP 文件,该文件是根据您的选择配置的 Web 应用程序的存档。...; @Controller public class GreetingController { @GetMapping("/greeting") public String greetingForm...Greeting()); return "greeting"; } @PostMapping("/greeting") public String greetingSubmit(@ModelAttribute...但是,在这种情况下,该greetingForm()方法具体映射到GETusing @GetMapping,而greetingSubmit()映射到POSTwith @PostMapping。...Greeting是 a ,因此@ModelAttribute它绑定到传入的表单内容。result另外,提交的数据可以通过名称引用(默认为方法参数的名称,greeting在本例中为)来呈现在视图中。

    2.5K20

    Spring Boot2 系列教程(十二)@ControllerAdvice 的三种使用场景

    使用步骤,首先定义全局数据,如下: @ControllerAdvice public class MyGlobalExceptionHandler { @ModelAttribute(name...注解标记该方法的返回数据是一个全局数据,默认情况下,这个全局数据的 key 就是返回的变量名,value 就是方法返回值,当然开发者可以通过 @ModelAttribute 注解的 name 属性去重新指定...定义完成后,在任何一个Controller 的接口中,都可以获取到这里定义的数据: @RestController public class HelloController { @GetMapping...("b") Book book, @ModelAttribute("a") Author author) { System.out.println(book); System.out.println...系列教程(七)理解自动化配置的原理 8、Spring Boot2 系列教程(八)Spring Boot 中配置 Https 9、Spring Boot2 系列教程(九)Spring Boot 整合 Thymeleaf

    1.1K11
    领券