zl程序教程

您现在的位置是:首页 >  大数据

当前栏目

boke练习: @PreAuthorize authentication.name.equals的数据绑定与验证

数据 验证 练习 绑定 name authentication equals
2023-09-14 08:57:51 时间

boke练习: @PreAuthorize authentication.name.equals的数据绑定与验证

先看2个简单的例子:

@PostMapping("/{username}/post")
	@PreAuthorize("authentication.name.equals(#categoryVO.username)")
	public ResponseEntity<Response> saveCategory(
			@RequestBody CategoryVO categoryVO
	)
	{
  。。。。。。。。。。。。。。。。。。。。。
}

  

@PostMapping("/{username}/post")
	@PreAuthorize("authentication.name.equals(#username)")
	public ResponseEntity<Response> saveCategory(
			@PathVariable("username") String username
	)
	{
。。。。。。。。。。
}

  

从2个例子中我们可以看出,如果要使用@PreAuthorize的authentication.name.equals判断,那么在public定义的方法中一定要有数据接收类型(如:String username,CategoryVO categoryVO)username,categoryVO,只有这个2个数据是能直接在authentication.name.equals中使用的.