视图层学习
controler
1.@RestController
写在类名上方,表示这个类用于接收浏览器值或传递数据给浏览器。引用对应着import org.springframework.web.bind.annotation.RestController;
package com.example.demo;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class hello {
}
2.@RequestMapping
写在类中方法名上方,表示浏览器可以通过这个标签的value配置的路径来访问这个类。里头有很多参数配置。
参数有:
value 写法 value=“” 引号之内写字符串。
menthod写法 method=RequestMethod.GET。RequestMethod后有很多传递方式。例如RequestMethod.POST,RequestMethod.PUT等等。
package com.example.demo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;**
import org.springframework.web.bind.annotation.RestController;
@RestController
public class hello {
@RequestMapping(value = "/hello",method = RequestMethod.GET)
public String hello()
{
return "hello springBoot";
}
}