首页 > 编程知识 正文

hasattr函数,@postconstruct注解

时间:2023-05-05 00:30:12 阅读:29104 作者:2240

首先,请检查@RequestMapping注释。

@RequestMapping是用于将url映射到控制器类的特定处理程序方法。 可以在方法和类上使用。 也就是说,可以在url中找到对应的方法。

@RequestMapping有八个属性。

value :指定请求的实际地址。

方法:指定请求的方法类型(GET、POST、PUT、DELETE )等。

consumes :指定处理请求的提交内容类型(Context-Type )。

produces :还可以指定返回的内容类型,并设置返回值的字符编码。

params :指定仅当请求包含特定参数值时才处理方法。

headers :如果请求中不包含某些指定的header值,方法将无法处理请求。

@getMapping和@postMapping是组合注释。

@ get mapping=@ request mapping (方法=request method.get )。

@ post mapping=@ request mapping (方法=request method.post )。

@GetMapping是组注释,是@ request mapping (method=request method.get )的缩写。 此注释将HTTP Get映射到特定的处理方法。

差异between @ get mapping @ request mapping :

@ getmappingdoesnotsupporttheconsumesattributeof @ request mapping。

在SpringBoot中,@GetMapping和@PostMapping测试相同的方法,但为什么@Get类型的注释访问成功,@PostMapping无法在浏览器中访问呢

@ controllerpublicclassjspcontroller { @ post mapping ('/index ' ) public string index (model model ) model.addattribute。 返回索引'; 在@PostMapping注释中,当浏览器输入访问位置时显示

thisapplicationhasnoexplicitmappingfor/error,so you are seeing this as a fallback。

Wed Feb 20 09:50:06 CST 2019

therewasanunexpectederror (类型=methodnotallowed,状态=405 )。

请求方法‘get’not supported

使用@GetMapping注释可以访问成功

从浏览器地址栏输入地址后,您访问的所有URL都是get请求,因此在开机自检中定义方法时,由于请求与实现不匹配,将返回405个错误。

浏览器发送获取请求的步骤

1 .在地址栏中直接输入地址

2 .点击链接

3 .如何提交表格默认

浏览器可以通过以下方式发送开机自检请求:

1 .将表单的方法设置为开机自检

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。