What is a hashtag ( # ) in Java/SpringBoot?

Melvin Roest :

This question most likely has been asked before. But I couldn't find it because searching a real hashtag in Google seems to be difficult. I suppose it's not called a hashtag and it's one of the relatively rare moments where my English fails me (2nd language).

So despite this being a duplicate, I'd argue to keep it on the site so that it is easier searchable via Google (and the SO site itself!).

I have the following code.

@GetMapping("/users")
@Timed
@PreAuthorize("hasAuthority('ADMINISTRATOR') or #oauth2.hasScope('some-user-list')")
public ResponseEntity<List<UserDTO>> getAllUsers(@ApiParam Pageable pageable) {
    final Page<UserDTO> page = userService.getAllUsers(pageable);
    HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/users");
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}

What does the # mean (in particular for #oauth2, I know what authentication is and what oauth does, I just don't understand the # as a concept in Spring)? How is it called? This doesn't seem to pertain to the Java language itself, so how does Spring Boot call this concept?

Kayaman :

It's part of the Spring Expression Language (Spring EL).

It allows you to write dynamic expressions, conditions and other things that would be impossible (or at least very clumsy) otherwise.

Similar expression languages exist in other frameworks (e.g. JSF EL), and they usually look very similar in syntax.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=74305&siteId=1