У меня есть бд блога на локалхосте я туда успешно гружу всю информацию для поста (название, дату , текст и картинку)
postAddArticle(@AuthenticationPrincipal User user, Date timeArticle, @RequestParam String title, String author,
@RequestParam String anons, @RequestParam String text,
@RequestParam("file") MultipartFile file, Model model)
<img src="data:image/jpeg;base64,[тут_код_картинки_в_base64]">
byte[] encodeBase64 = Base64.encode(repository.getImage());
String base64Encoded = new String(encodeBase64, "UTF-8");
model.addObject("image", base64Encoded );
<img src="data:image/jpeg;base64,${image}" />
.category-menu .et_pb_menu__menu li.first-level {
border-bottom: 2px solid #ff0000;
}
Вообще мне кажется у вас архитектурно не очень придумано.
Лучше бы сделать отдельно пользователей и отдельно роли.
Converter<S, T>
)Primitive objects and classes
A primitive object is a class instance that does not have identity. That is, a primitive object does not have a fixed memory address or any other property to distinguish it from other instances of the same class whose fields store the same values. Primitive objects cannot mutate their fields or be used for synchronization. The == operator on primitive objects compares their fields. Concrete classes whose instances are primitive objects are called primitive classes.
^((?!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