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

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中使用的.

 

posted @ 2018-10-29 09:56  穆晟铭  阅读(878)  评论(0编辑  收藏  举报