그것은 각각 thymeleaf th로 멈출 수 있습니까? 내 문제는 이것입니다 :내 조건이 만족되면 박리 잎 브레이크 루프
제목이 여러 번 표시됩니다 ... 데이터베이스의 모든 항목에 대해 하나의 제목.
html 코드 :
<div class="container">
<div class="row">
<div th:each="movie : ${movies}" class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<div th:each="movieUser : ${movieUserWatched}">
<h4 th:if="${movie.id} == ${movieUser.id}">
<i style="float: left; color: green; margin-right: 2%;"
class="fa fa-check-circle"> </i> <span class="info-box-number"
th:text="${movie.title}">MovieName</span>
</h4>
<h4 th:unless="${movie.id} == ${movieUser.id}">
<span class="info-box-number" th:text="${movie.title}">MovieName</span>
</h4>
</div>
</div>
<div class="panel-body">
<div class="col-md-5">
<img
style="margin-left: -16%; margin-bottom: -8%; opacity: 1; margin-top: -8%;"
data-sizes="auto" th:alt="${movie.title}"
th:src="@{${movie.poster_path}}">
</div>
<div class="col-md-7">Genre Infos</div>
</div>
<div class="panel-footer">
<a href="#" th:href="@{'/movie/' + ${movie.id} }"
class="small-box-footer">More info <i
class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- /.box -->
</div>
</div>
</div>
컨트롤러 코드 2 개 목록에 대한 :
@RequestMapping(value = ("/movies"))
public String Movie(Model model) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
User currentUser = userDao.findOneByUsername(auth.getName());
Iterable<Movie> movie = movieDao.findAll();
List<UserMovie> UserWatched = currentUser.getUserMovies();
List<Movie> movieUserWatched = new ArrayList<Movie>();
for(UserMovie u: UserWatched){
movieUserWatched.add(u.getMovie());
}
model.addAttribute("movies", movie);
model.addAttribute("movieUserWatched", movieUserWatched);
return "home/movies";
}
희망을 보내주세요. :)
당신은 서버 측에서 중복 필터링 더 나을 수도 작동합니다, 코드 아래에보십시오. 간단한 해결책은 'Set'또는 더 나은 방법을 사용하여 쿼리를 업데이트하여 다른 결과를 반환하는 것입니다. – bphilipnyc
어떻게해야할지 모르겠습니다. 예를 들어 줄 수 있습니까? – Damlo
텍스트 또는 텍스트 데이터의 스크린 샷을 게시하거나 링크하지 마십시오. 텍스트 자체를 질문에 복사/붙여 넣기하십시오. – BSMP