uimping0 13 de jan. de 2021
Problema resolvido das duas maneiras que eu queria agora basta o cliente escolher kkkkk
@GetMapping ( "/images" )
public ModelAndView getImages () {
ArrayList < String > listage_img = new ArrayList <> ();
ModelAndView mv = new ModelAndView ( "upload" );
File file2 = new File ( UPLOAD_FOLDER );
File [] arquivos = file2 . listFiles ();
for ( int i = 0 ; i < arquivos . length ; i ++ ) {
System . out . println ( arquivos [ i ] . getName ());
listage_img . add ( arquivos [ i ] . getName ());
mv . addObject ( "listage_img" , listage_img );
}
return mv ;
}
Esse é o código na classe controller
E esse é o código na parte do html com thymeleaf
<select name= "category" >
<option th:each= "listage_img: ${ listage_img } " th:text= " ${ listage_img } " ></option>
</select>
<section>
<div class= "container" style= "width: 60%; padding-bottom: 30px;" >
<div class= "row" >
<div class= "col-lg-3" th:each= "listage_img: ${ listage_img } " >
<div class= "card shadow-sm bg-white rounded" style= "width: 14em; margin-top: 20px; align-items: center;" >
<img class= "card-img-top" style= "width: 200px; height: 200px" th:attr= "src=@{'/images/' + ${ listage_img } +''}" >
<div class= "card-body" >
<p class= "card-text" >
<span th:text= " ${ listage_img } " ></span>
</p>
</div>
</div>
</div>
</div>
</div>
</section>
mas é batata e ainda fica uma imagem do lado da outra…