Here is my JpaRepository
public interface ProcessorRepository extends JpaRepository<Processor, Integer> {
}
Controller
...
@Autowired
ProcessorRepository processorRepository;
@RequestMapping("/getAll")
public String showAllProcessors(Map map){
List<Processor> processorList = processorRepository.findAll();
map.put("processors", processorList);
return "main";
}
main.jsp
....
<select>
<option selected="selected">Choose Processor</option>
<c:forEach var="proc" items="${processors}">
<option>
${proc.processorName}
</option>
</c:forEach>
</select>
This is how Processor mysql table looks like:
But this is what I get
Why it returns duplicates of first row, instead of all different rows?
Turned out the problem was in my Processor entity. It had @Column(name="id") instead of @Column(name="processor_id").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With