^((?!jpg|png|mp3)[\s\S])*$
enctype="multipart/form-data"
Как в IntelliJ IDEA в проекте в директории src создать поддиректории?
<link href="${pageContext.request.contextPath}/templates/bootstrap/plugins/fontawesome-free/css/all.min.css" rel="stylesheet">
<script th:src="@{/bootstrap/plugins/bootstrap/js/bootstrap.bundle.min.js}"></script>
@ControllerAdvice
@ControllerAdvice
public class GlobalControllerAdvice {
// Текущий авторизованный пользователь
@ModelAttribute("user")
public User getUserProfile(
@AuthenticationPrincipal UserDetails currentUser
) {
if(
SecurityContextHolder.getContext().getAuthentication() != null &&
SecurityContextHolder.getContext().getAuthentication().isAuthenticated() &&
!(SecurityContextHolder.getContext().getAuthentication() instanceof AnonymousAuthenticationToken)
) {
return (User) userService.findUserByEmail(currentUser.getUsername());
} else {
return null;
}
}
}
if(user != null){
model.addAttribute("user", user.getUsername());
return "/index";
} else {
model.addAttribute("user", "Аноним");
return "/index";
}
@PostMapping("/order")
public void pay(@AuthenticationPrincipal AuthorizedUser user) {
...
}
@PostMapping("/order")
public void pay(@RequestParam(value = "consumer-id") Integer consumerId,
@RequestParam(value = "consumer-region-code") Integer regionCode) {
...
}
@PostMapping("/order")
public void pay(
@AuthenticationPrincipal AuthorizedUser user,
@RequestParam(value = "consumer-id", required = false) Integer consumerId,
@RequestParam(value = "consumer-region-code", required = false) Integer regionCode
) {
...
}
getClass().getResourceAsStream()
resources/data
/clients/{clientId}
/clients/6
@PathVariable Integer
Optional client = null;
try {
client = clientRepository.findById(clientId);
model.addAttribute("allowDelete", false);
} catch (Exception ex) {
model.addAttribute("errorMessage", ex.getMessage());
}
model.addAttribute("client", client);
@GetMapping(value = "/clients/{clientId}")
public String clientDetails(Model model, @PathVariable Integer clientId) {
Optional client = clientRepository.findById(clientId).orElseThrow(ClientNotFoundException::new);
model.addAttribute("client", client);
return "client-details";
}
{{#clients}}
{{#client}}
UserRequestDto {
@NotBlank(message = "Name is mandatory")
String username;
@NotBlank(message = "Email is mandatory")
String email;
}
//@RestController
@Controller
UserController {
public ResponseEntity<User> addUser( @Valid UserDto user ) {
// конвертируем UserDto -> User и в передаем в сервисный класс для сохранения
}
}
<input type="email" />
import com.sun.istack.NotNull;
, а должно быть hibernate validator. if (c == ('q'))
break;
System.exit(0);
Dog -> Animal Cat -> Animal
UserService {
Connection connection;
}
<div sec:authorize="hasRole('ROLE_ADMIN')">
This will only be displayed if authenticated user has role ROLE_ADMIN.
</div>