Posts

image work in springboot

 Bean file :         @Lob @Column(length = Integer.MAX_VALUE) private byte[] images;          public byte[] getImages() {           return images;            }          public void setImages(byte[] images) {           this.images = images;            } save image controller :       @PostMapping("/") public String saveHolidayPackage(@ModelAttribute CreateHolidayPackageOne createHolidayPackageOne,               @RequestParam("image") MultipartFile file,HttpSession httpSession) throws IOException { createHolidayPackageOne.setImages(file.getBytes()); createHolidayPackageOneRepo.save(createHolidayPackageOne); return "Admin/CreateHolidayPackageDetails"; } retrieve image from database controller :         ...

including thymeleaf template | include | insert | replace

Image
  footer.html <footer th:fragement="footer1"> .......................................... </footer> index.html <footer  the:replace="footer::footer1">  .............................................................. </footer>

delete query in springboot

  Let's check the equivalent code for our derived method from earlier: @Modifying @Query("delete from Book b where b.title=:title") void deleteBooks ( @Param("title") String title) ;

to form get date set into RequestMapping to @RequestParam takes date

in request Data from form........  @RequestParam("StartDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate strdate Also declare bean in , @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDate dob;

Springboot important annotation

Image
  Spring Boot Annotations Spring Boot’s annotations are key to getting up to speed with the framework. They allow you to direct the framework to do your bidding, taking control and overriding its defaults when needed. Annotations are quick, easy to use, and orders of magnitude faster than building the equivalent functionality yourself. You can learn more in Spring’s documentation. The  PDF  or  web  versions are essential reading if you plan on working with Spring Boot. Knowing how to use annotations can level up your game and help you get the most out of the framework. Listed below are several common annotations, some of them with sample code. Spring Boot works with  Java ,  Kotlin , and Groovy. I’ll use Java for the examples in this article. Basic Setup @SpringBootApplication @Configuration @ComponentScan @EnableAutoConfiguration Request Responses @GetMapping @RequestMapping @RequestParam Component Types @Component @Service @Repository @Controller @R...