package com.kuang.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller//代表这个类会被SPring接管
//被这个类注解的类中的所有方法,如果返回值是String,并且有具体的页面可以跳转那么就会被视图解析器解析;
public class ControllerTest2 {
@RequestMapping("/t2")
//@RequestMapping注解用于映射url到控制器类或一个特定的处理程序方法。可用于类或者方法上,
//用于类上,表示类中的所有相应请求的方法都是以该地址作为父路径。
public String test1(Model model){
model.addAttribute("msg", "阿里巴巴");
return "test"; //WEB-INF/jsp/rest.jsp
}
@RequestMapping("/t3")
public String test2(Model model){
model.addAttribute("msg", "华为");
return "test";
}
}
注解开发常用,比较简单。