I am using the spring MVC model attribute approach. When opening a screen i got to read a JSON string and create a map. Display the map in a drop down list. I could see the values in HTML source code but not seeing the drop down in the screen.
@RequestMapping("/xxx")
public ModelAndView saws(Map<String, Object> model1) throws IOException {
ModelAndView model = new ModelAndView("xxx");
model.addObject("message", this.welcome);
Map<String, String> offers = engine.getOffers();
model.addObject("offers", offers);//map of offers
model.addObject("inputs", new inputs());
return model;
}
JSP
<form:form action="getoffers" method="get" modelAttribute="inputs">
<body>
<table align="center">
<tr class="blank_row">
<td colspan="2"></td>
</tr>
<tr class="blank_row">
<td colspan="2"></td>
</tr>
<tr align="center">
<th span
style="color: red; font-weight: bold; word-wrap: break-word;"
align="center">Select the service to view current offers</th>
</tr>
<tr>
<td><form:select path="offers">
<form:options items="${offers}" />
</form:select></td>
</tr>
</table>
And in the screen i don't see the drop down.when i check the source code I see this. Pls see the pictures
Assume you already had the sping-mvc dependency.
The html source file is not supposed to have <form:...>
prefix. It is not rendered correctly.
Put this in your jsp file:
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
I highly recommend that you use Thymeleaf template engine instead of JSP. The reasons are too long to fit in this answer area.